Skip to content

Commit

Permalink
FORGE-2316: Added default method getStack() to Project
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jan 14, 2016
1 parent 0951c74 commit f079dbe
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

package org.jboss.forge.addon.projects;

import java.util.Optional;

import org.jboss.forge.addon.facets.Faceted;
import org.jboss.forge.addon.projects.stacks.Stack;
import org.jboss.forge.addon.projects.stacks.StackFacet;
import org.jboss.forge.addon.resource.DirectoryResource;
import org.jboss.forge.addon.resource.Resource;

Expand Down Expand Up @@ -49,4 +53,19 @@ default DirectoryResource getRootDirectory()
* Get the {@link Resource} representing the root of this {@link Project}.
*/
Resource<?> getRoot();

/**
* A project may have a stack associated with it
*
* @return an {@link Optional} containing the associated stack
*/
default Optional<Stack> getStack()
{
Stack stack = null;
if (hasFacet(StackFacet.class))
{
stack = getFacet(StackFacet.class).getStack();
}
return Optional.ofNullable(stack);
}
}

0 comments on commit f079dbe

Please sign in to comment.