private void setDependency(Dependency dependency) { Assert.notNull(dependency, "Dependency must be set"); this.dependency = dependency; }
/** * Install the given facets without prompting for confirmation */ public InstallFacets(final Class<? extends Facet>... facetTypes) { // FIXME This method causes warnings when used as intended... fix? Assert.notNull(facetTypes, "Facet types may not be null."); this.facetTypes = Arrays.asList(facetTypes); }
/** * Install the given facets without prompting for confirmation */ public RemoveFacets(final Class<? extends Facet>... facetTypes) { // FIXME This method causes warnings when used as intended... fix? Assert.notNull(facetTypes, "Facet types may not be null."); this.facetTypes = Arrays.asList(facetTypes); }
/** * Return the index of the last element of this List, if any (size - 1), if the list is empty, return 0; */ public static int indexOfLastElement(List<?> list) { Assert.notNull(list, "Argument List<?> must not be null."); return list.size() == 0 ? 0 : list.size() - 1; }
/** * Install the given facet without prompting for confirmation */ public InstallFacets(final Class<? extends Facet> facetType) { Assert.notNull(facetType, "Facet type may not be null."); this.facetTypes = new ArrayList<Class<? extends Facet>>(); facetTypes.add(facetType); }
/** * Install the given facet without prompting for confirmation */ public RemoveFacets(final Class<? extends Facet> facetType) { Assert.notNull(facetType, "Facet type may not be null."); this.facetTypes = new ArrayList<Class<? extends Facet>>(); facetTypes.add(facetType); }
/** * Return the the last element of this List, if any. If the list contains elements, return the element at index: * "size - 1", if the list is empty, return null; */ public static <T> T lastElement(List<T> list) { Assert.notNull(list, "Argument List<?> must not be null."); if (list.isEmpty()) return null; return list.get(list.size() - 1); } }
@SuppressWarnings("unchecked") public static <T> T[] join(Class<T> type, T[] front, T... back) { Assert.notNull(type, "Type must not be null."); Assert.notNull(front, "Target array must not be null."); Assert.notNull(back, "Source array must not be null."); T[] dest = front; int size = 0; if (front != null) size = front.length; if (back != null) size += back.length; dest = (T[]) Array.newInstance(type, size); if (dest.length > 1) { System.arraycopy(front, 0, dest, 0, front.length); System.arraycopy(back, 0, dest, front.length, back.length); } return dest; }
public static boolean isApiCompatible(CharSequence runtimeVersion, PluginEntry entry) { Assert.notNull(runtimeVersion, "Runtime API version must not be null."); Assert.notNull(entry, "Plugin entry must not be null."); String pluginApiVersion = entry.getApiVersion(); Assert.notNull(pluginApiVersion, "Plugin entry.getApiVersion() must not be null."); return isApiCompatible(runtimeVersion, pluginApiVersion); }
public static Visibility getFrom(VisibilityScoped<?> target) { Assert.notNull(target, "VisibilityScoped<T> target must not be null."); if (target.isPackagePrivate()) return PACKAGE_PRIVATE; if (target.isPrivate()) return PRIVATE; if (target.isPublic()) return PUBLIC; if (target.isProtected()) return PROTECTED; else { throw new IllegalStateException(VisibilityScoped.class.getSimpleName() + " target does not comply with visibility scoping. Must be one of " + Visibility.values() + "[ " + target + "]"); } }
public static <T extends VisibilityScoped<?>> T set(T target, Visibility scope) { Assert.notNull(target, "VisibilityScoped<T> target must not be null."); Assert.notNull(scope, "Visibility scope must not be null"); if (PRIVATE.equals(scope)) target.setPrivate(); else if (PACKAGE_PRIVATE.equals(scope)) target.setPackagePrivate(); else if (PROTECTED.equals(scope)) target.setProtected(); else if (PUBLIC.equals(scope)) target.setPublic(); else { throw new IllegalStateException("Unknown Visibility scope."); } return target; } }
@Command("set-version") public void setVersion(final PipeOut out, @Option(description = "the new version; for example: \"1.0.0.Final\"") final String version) { Assert.notNull(version, "GroupId must not be empty"); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.setVersion(version); mvn.setPOM(pom); out.println("Set version [ " + version + " ]"); }
@Command("set-groupid") public void setGroupId(final PipeOut out, @Option(description = "the new groupId; for example: \"org.jboss.forge\"") final String groupId) { Assert.notNull(groupId, "GroupId must not be empty"); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.setGroupId(groupId); mvn.setPOM(pom); out.println("Set groupId [ " + groupId + " ]"); }
@Command("set-artifactid") public void setArtifactId(final PipeOut out, @Option(description = "the new artifactId; for example: \"forge-shell\"") final String artifactId) { Assert.notNull(artifactId, "GroupId must not be empty"); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.setArtifactId(artifactId); mvn.setPOM(pom); out.println("Set artifactId [ " + artifactId + " ]"); }
@Command("set-name") public void setName(final PipeOut out, @Option(description = "the new name; for example: \"UI-Layer\"") final String name) { Assert.notNull(name, "Name must not be empty"); MavenCoreFacet mvn = project.getFacet(MavenCoreFacet.class); Model pom = mvn.getPOM(); pom.setName(name); mvn.setPOM(pom); out.println("Set name [ " + name + " ]"); }