List of usage examples for org.apache.commons.lang ArrayUtils add
public static short[] add(short[] array, short element)
Copies the given array and adds the given element at the end of the new array.
From source file:info.magnolia.cms.security.auth.callback.CompositeCallback.java
public void addPattern(PatternDelegate pattern) { this.patterns = (PatternDelegate[]) ArrayUtils.add(this.patterns, pattern); }
From source file:hudson.plugins.mercurial.MercurialContainer.java
public MercurialInstallation createInstallation(JenkinsRule r, Version v, boolean debug, boolean useCaches, boolean useSharing, String config, Slave... slaves) throws IOException { MercurialInstallation.DescriptorImpl desc = r.jenkins .getDescriptorByType(MercurialInstallation.DescriptorImpl.class); ToolLocationNodeProperty.ToolLocation location = new ToolLocationNodeProperty.ToolLocation(desc, v.name(), "/opt/mercurial-" + v.exactVersion); MercurialInstallation inst = new MercurialInstallation(v.name(), "", "INSTALLATION/hg", debug, useCaches, useSharing, config, null);//w ww . j av a 2 s . co m desc.setInstallations((MercurialInstallation[]) ArrayUtils.add(desc.getInstallations(), inst)); // TODO stop calling this here, should be responsibility of caller for (Slave slave : slaves) { DescribableList<NodeProperty<?>, NodePropertyDescriptor> props = slave.getNodeProperties(); ToolLocationNodeProperty prop = props.get(ToolLocationNodeProperty.class); List<ToolLocationNodeProperty.ToolLocation> locations; if (prop == null) { locations = Collections.singletonList(location); } else { locations = new ArrayList<>(prop.getLocations()); locations.add(location); } props.replace(new ToolLocationNodeProperty(locations)); } return inst; }
From source file:com.aionemu.gameserver.restrictions.RestrictionsManager.java
public synchronized static void activate(Restrictions restriction) { for (Method method : restriction.getClass().getMethods()) { RestrictionMode mode = RestrictionMode.parse(method); if (mode == null) { continue; }/*from w w w .java2 s. c o m*/ if (method.getAnnotation(DisabledRestriction.class) != null) { continue; } Restrictions[] restrictions = RESTRICTIONS[mode.ordinal()]; if (!ArrayUtils.contains(restrictions, restriction)) { restrictions = (Restrictions[]) ArrayUtils.add(restrictions, restriction); } Arrays.sort(restrictions, mode); RESTRICTIONS[mode.ordinal()] = restrictions; } }
From source file:gda.device.scannable.DummyContinuouslyScannable.java
/** * For testing and simulation only. Real hardware represented by the ContinuousScannable and DummyHistogramDetector * interfaces would be physically wired together. * /*from w w w . j av a 2s . c o m*/ * @param detector */ public void addObserver(final SimulatedBufferedDetector detector) { if (!ArrayUtils.contains(observers, detector)) { observers = (SimulatedBufferedDetector[]) ArrayUtils.add(observers, detector); } }
From source file:gda.device.scannable.scannablegroup.ScannableGroup.java
@Override public void addGroupMemberName(String groupMemberName) { if (!ArrayUtils.contains(groupMemberNames, groupMemberName)) { groupMemberNames = (String[]) ArrayUtils.add(groupMemberNames, groupMemberName); }/* w w w . ja va 2s . c o m*/ }
From source file:de.ingrid.admin.Utils.java
public static void addDatatypeToIndex(String index, String type) { Config config = JettyStarter.getInstance().config; if (config.datatypesOfIndex != null) { String[] types = config.datatypesOfIndex.get(index); if (types != null) { if (!ArrayUtils.contains(types, type)) { config.datatypesOfIndex.put(index, (String[]) ArrayUtils.add(types, type)); if (!config.datatypes.contains(type)) { config.datatypes.add(type); }//from w w w . java 2 s . co m } } } }
From source file:au.org.ala.biocache.dao.TaxonDAOImpl.java
@Override public void extractHierarchy(String metadataUrl, String q, String[] fq, Writer writer) throws Exception { List<FacetField.Count> kingdoms = extractFacet(q, fq, "kingdom"); for (FacetField.Count k : kingdoms) { outputNestedLayerStart(k.getName(), writer); List<FacetField.Count> phyla = extractFacet(q, (String[]) ArrayUtils.add(fq, "kingdom:" + k.getName()), "phylum"); for (FacetField.Count p : phyla) { outputNestedMappableLayerStart("phylum", p.getName(), writer); List<FacetField.Count> classes = extractFacet(q, (String[]) ArrayUtils.add(fq, "phylum:" + p.getName()), "class"); for (FacetField.Count c : classes) { outputNestedMappableLayerStart("class", c.getName(), writer); List<FacetField.Count> orders = extractFacet(q, (String[]) ArrayUtils.add(fq, "class:" + c.getName()), "order"); for (FacetField.Count o : orders) { outputNestedMappableLayerStart("order", o.getName(), writer); List<FacetField.Count> families = extractFacet(q, (String[]) ArrayUtils.addAll(fq, new String[] { "order:" + o.getName(), "kingdom:" + k.getName() }), "family"); for (FacetField.Count f : families) { outputNestedMappableLayerStart("family", f.getName(), writer); List<FacetField.Count> genera = extractFacet(q, (String[]) ArrayUtils.addAll(fq, new String[] { "family:" + f.getName(), "kingdom:" + k.getName() }), "genus"); for (FacetField.Count g : genera) { outputNestedMappableLayerStart("genus", g.getName(), writer); List<FacetField.Count> species = extractFacet(q, (String[]) ArrayUtils.addAll(fq, new String[] { "genus:" + g.getName(), "kingdom:" + k.getName(), "family:" + f.getName() }), "species"); for (FacetField.Count s : species) { outputLayer(metadataUrl, "species", s.getName(), writer); }/*from w w w . j a va 2s . c o m*/ outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } }
From source file:gda.device.scannable.CoupledScannable.java
/** * Adds a Scannable. * * @param newScannable */ public void addScannable(Scannable newScannable) { theScannables = (Scannable[]) ArrayUtils.add(theScannables, newScannable); }
From source file:net.shopxx.dao.impl.ArticleCategoryDaoImpl.java
private void sort(List<ArticleCategory> articleCategories) { if (CollectionUtils.isEmpty(articleCategories)) { return;/*ww w .j a v a 2 s . co m*/ } final Map<Long, Integer> orderMap = new HashMap<Long, Integer>(); for (ArticleCategory articleCategory : articleCategories) { orderMap.put(articleCategory.getId(), articleCategory.getOrder()); } Collections.sort(articleCategories, new Comparator<ArticleCategory>() { @Override public int compare(ArticleCategory articleCategory1, ArticleCategory articleCategory2) { Long[] ids1 = (Long[]) ArrayUtils.add(articleCategory1.getParentIds(), articleCategory1.getId()); Long[] ids2 = (Long[]) ArrayUtils.add(articleCategory2.getParentIds(), articleCategory2.getId()); Iterator<Long> iterator1 = Arrays.asList(ids1).iterator(); Iterator<Long> iterator2 = Arrays.asList(ids2).iterator(); CompareToBuilder compareToBuilder = new CompareToBuilder(); while (iterator1.hasNext() && iterator2.hasNext()) { Long id1 = iterator1.next(); Long id2 = iterator2.next(); Integer order1 = orderMap.get(id1); Integer order2 = orderMap.get(id2); compareToBuilder.append(order1, order2).append(id1, id2); if (!iterator1.hasNext() || !iterator2.hasNext()) { compareToBuilder.append(articleCategory1.getGrade(), articleCategory2.getGrade()); } } return compareToBuilder.toComparison(); } }); }
From source file:net.shopxx.dao.impl.ProductCategoryDaoImpl.java
private void sort(List<ProductCategory> productCategories) { if (CollectionUtils.isEmpty(productCategories)) { return;//from w w w . j a v a2s. c om } final Map<Long, Integer> orderMap = new HashMap<Long, Integer>(); for (ProductCategory productCategory : productCategories) { orderMap.put(productCategory.getId(), productCategory.getOrder()); } Collections.sort(productCategories, new Comparator<ProductCategory>() { @Override public int compare(ProductCategory productCategory1, ProductCategory productCategory2) { Long[] ids1 = (Long[]) ArrayUtils.add(productCategory1.getParentIds(), productCategory1.getId()); Long[] ids2 = (Long[]) ArrayUtils.add(productCategory2.getParentIds(), productCategory2.getId()); Iterator<Long> iterator1 = Arrays.asList(ids1).iterator(); Iterator<Long> iterator2 = Arrays.asList(ids2).iterator(); CompareToBuilder compareToBuilder = new CompareToBuilder(); while (iterator1.hasNext() && iterator2.hasNext()) { Long id1 = iterator1.next(); Long id2 = iterator2.next(); Integer order1 = orderMap.get(id1); Integer order2 = orderMap.get(id2); compareToBuilder.append(order1, order2).append(id1, id2); if (!iterator1.hasNext() || !iterator2.hasNext()) { compareToBuilder.append(productCategory1.getGrade(), productCategory2.getGrade()); } } return compareToBuilder.toComparison(); } }); }