/** * <p>Finds the last index of the given value in the array starting at the given index.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the * array length will search from the end of the array.</p> * * @param array the array to traverse for looking for the object, may be <code>null</code> * @param valueToFind the value to find * @param startIndex the start index to travers backwards from * @return the last index of the value within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int lastIndexOf(double[] array, double valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return INDEX_NOT_FOUND; } if (startIndex < 0) { return INDEX_NOT_FOUND; } else if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; i--) { if (valueToFind == array[i]) { return i; } } return INDEX_NOT_FOUND; }
/** * <p>Finds the last index of the given value in the array starting at the given index.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than * the array length will search from the end of the array.</p> * * @param array the array to traverse for looking for the object, may be <code>null</code> * @param valueToFind the value to find * @param startIndex the start index to travers backwards from * @return the last index of the value within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int lastIndexOf(boolean[] array, boolean valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return INDEX_NOT_FOUND; } if (startIndex < 0) { return INDEX_NOT_FOUND; } else if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; i--) { if (valueToFind == array[i]) { return i; } } return INDEX_NOT_FOUND; }
/** * <p>Finds the index of the given value in the array starting at the given index.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex is treated as zero. A startIndex larger than the array * length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p> * * @param array the array to search through for the object, may be <code>null</code> * @param valueToFind the value to find * @param startIndex the index to start searching at * @return the index of the value within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int indexOf(float[] array, float valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return INDEX_NOT_FOUND; } if (startIndex < 0) { startIndex = 0; } for (int i = startIndex; i < array.length; i++) { if (valueToFind == array[i]) { return i; } } return INDEX_NOT_FOUND; }
public void setAdditionalNonPersistentProperties(String[] additionalNonPersistentProperties) { this.additionalNonPersistentProperties = additionalNonPersistentProperties; if (!ArrayUtils.isEmpty(this.additionalNonPersistentProperties)) { Arrays.sort(this.additionalNonPersistentProperties); } }
public void setAdditionalForeignKeys(ForeignKey[] additionalForeignKeys) { this.additionalForeignKeys = additionalForeignKeys; if (!ArrayUtils.isEmpty(this.additionalForeignKeys)) { Arrays.sort(this.additionalForeignKeys, new Comparator<ForeignKey>() { public int compare(ForeignKey o1, ForeignKey o2) { return o1.getManyToField().compareTo(o2.getManyToField()); } }); } }
/** * Set the list of fields to include in the admin presentation. * Implementations should use excludeFields instead. * * @param includeManyToOneFields */ @Deprecated public void setIncludeFields(String[] includeManyToOneFields) { this.includeFields = includeManyToOneFields; if (!ArrayUtils.isEmpty(this.includeFields)) { Arrays.sort(this.includeFields); } }
private void handleError(File[] files) { if (ArrayUtils.isEmpty(files)) { LOG.error("No jdbc standalone jar found in the directory " + JDBC_JAR_DIR); } else { StringBuilder fileNames = new StringBuilder(); for (File file : files) { fileNames.append("\t" + file.getAbsolutePath() + "\n"); } LOG.error("Multiple jdbc standalone jars exist in the directory " + JDBC_JAR_DIR + ":\n" + fileNames); } } }
/** * @param keys the languages keys * @return the list of suffix files associates to languages included in the current object */ public String[] getSuffixes(String... keys) { List<String> suffixes = new ArrayList<>(); for (Map.Entry<String, Language> entry : map.entrySet()) { if (ArrayUtils.isEmpty(keys) || ArrayUtils.contains(keys, entry.getKey())) { suffixes.addAll(Arrays.asList(entry.getValue().getFileSuffixes())); } } return suffixes.toArray(new String[suffixes.size()]); }
/** * <p>Takes an argument in set-syntax, see evaluateSet, * and deletes any of characters present in the specified string.</p> * * <p>An example would be:</p> * <ul> * <li>delete("hello", {"c-f", "o"}) returns * "hll"</li> * </ul> * * @see CharSet#getInstance(java.lang.String) for set-syntax. * @param str String to delete characters from, may be null * @param set String[] set of characters to delete, may be null * @return modified String, <code>null</code> if null string input */ public static String delete(String str, String[] set) { if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) { return str; } return modify(str, set, false); }
/** * <p>Takes an argument in set-syntax, see evaluateSet, * and keeps any of characters present in the specified string.</p> * * <p>An example would be:</p> * <ul> * <li>keep("hello", {"c-f", "o"}) * returns "eo"</li> * </ul> * * @see CharSet#getInstance(java.lang.String) for set-syntax. * @param str String to keep characters from, may be null * @param set String[] set of characters to keep, may be null * @return modified String, <code>null</code> if null string input * @since 2.0 */ public static String keep(String str, String[] set) { if (str == null) { return null; } if (str.length() == 0 || ArrayUtils.isEmpty(set)) { return ""; } return modify(str, set, true); }
@Override public Boolean canHandleAdd(PersistencePackage persistencePackage) { String ceilingEntityFullyQualifiedClassname = persistencePackage.getCeilingEntityFullyQualifiedClassname(); String[] customCriteria = persistencePackage.getCustomCriteria(); return !ArrayUtils.isEmpty(customCriteria) && "categoryDirectEdit".equals(customCriteria[0]) && Category.class.getName().equals(ceilingEntityFullyQualifiedClassname); }
@Override public Boolean canHandleAdd(PersistencePackage persistencePackage) { String ceilingEntityFullyQualifiedClassname = persistencePackage.getCeilingEntityFullyQualifiedClassname(); String[] customCriteria = persistencePackage.getCustomCriteria(); return !ArrayUtils.isEmpty(customCriteria) && "productDirectEdit".equals(customCriteria[0]) && Product.class.getName().equals(ceilingEntityFullyQualifiedClassname); }
@Override public Boolean canHandleAdd(PersistencePackage persistencePackage) { String ceilingEntityFullyQualifiedClassname = persistencePackage.getCeilingEntityFullyQualifiedClassname(); String[] criteria = persistencePackage.getCustomCriteria(); return !ArrayUtils.isEmpty(criteria) && criteria[0].equals("createNewPermission") && AdminPermission.class.getName().equals(ceilingEntityFullyQualifiedClassname); }
protected boolean canHandleAnnotationOverride(OverrideViaAnnotationRequest overrideViaAnnotationRequest, Map<String, FieldMetadata> metadata) { AdminPresentationOverrides myOverrides = overrideViaAnnotationRequest.getRequestedEntity().getAnnotation(AdminPresentationOverrides.class); AdminPresentationMergeOverrides myMergeOverrides = overrideViaAnnotationRequest.getRequestedEntity().getAnnotation(AdminPresentationMergeOverrides.class); return (myOverrides != null && (!ArrayUtils.isEmpty(myOverrides.value()) || !ArrayUtils.isEmpty(myOverrides .toOneLookups()) || !ArrayUtils.isEmpty(myOverrides.dataDrivenEnums()))) || myMergeOverrides != null; }
protected boolean canHandleAnnotationOverride(OverrideViaAnnotationRequest overrideViaAnnotationRequest, Map<String, FieldMetadata> metadata) { AdminPresentationOverrides myOverrides = overrideViaAnnotationRequest.getRequestedEntity().getAnnotation(AdminPresentationOverrides.class); AdminPresentationMergeOverrides myMergeOverrides = overrideViaAnnotationRequest.getRequestedEntity().getAnnotation(AdminPresentationMergeOverrides.class); return (myOverrides != null && !ArrayUtils.isEmpty(myOverrides.collections()) || myMergeOverrides != null); }
protected boolean canHandleAnnotationOverride(OverrideViaAnnotationRequest overrideViaAnnotationRequest, Map<String, FieldMetadata> metadata) { AdminPresentationOverrides myOverrides = overrideViaAnnotationRequest.getRequestedEntity().getAnnotation(AdminPresentationOverrides.class); AdminPresentationMergeOverrides myMergeOverrides = overrideViaAnnotationRequest.getRequestedEntity().getAnnotation(AdminPresentationMergeOverrides.class); return (myOverrides != null && !ArrayUtils.isEmpty(myOverrides.maps())) || myMergeOverrides != null; }
protected boolean canHandleAnnotationOverride(OverrideViaAnnotationRequest overrideViaAnnotationRequest, Map<String, FieldMetadata> metadata) { AdminPresentationOverrides myOverrides = overrideViaAnnotationRequest.getRequestedEntity().getAnnotation(AdminPresentationOverrides.class); AdminPresentationMergeOverrides myMergeOverrides = overrideViaAnnotationRequest.getRequestedEntity().getAnnotation(AdminPresentationMergeOverrides.class); return (myOverrides != null && !ArrayUtils.isEmpty(myOverrides.adornedTargetCollections())) || myMergeOverrides != null; }
private void setDeprecationAndSuggestedStep() { PluginRegistry registry = PluginRegistry.getInstance(); final List<PluginInterface> deprecatedSteps = registry.getPluginsByCategory( StepPluginType.class, BaseMessages.getString( PKG, "BaseStep.Category.Deprecated" ) ); for ( PluginInterface p : deprecatedSteps ) { String[] ids = p.getIds(); if ( !ArrayUtils.isEmpty( ids ) && ids[0].equals( this.stepid ) ) { this.isDeprecated = true; this.suggestion = registry.findPluginWithId( StepPluginType.class, this.stepid ) != null ? registry.findPluginWithId( StepPluginType.class, this.stepid ).getSuggestion() : ""; break; } } }
private void updateRawScanByCurrentRegion(RawScan rawScan, HRegion region, int shardLength) { if (shardLength == 0) { return; } byte[] regionStartKey = ArrayUtils.isEmpty(region.getRegionInfo().getStartKey()) ? new byte[shardLength] : region.getRegionInfo().getStartKey(); Bytes.putBytes(rawScan.startKey, 0, regionStartKey, 0, shardLength); Bytes.putBytes(rawScan.endKey, 0, regionStartKey, 0, shardLength); }
private void setDeprecationAndSuggestedJobEntry() { PluginRegistry registry = PluginRegistry.getInstance(); final List<PluginInterface> deprecatedJobEntries = registry.getPluginsByCategory( JobEntryPluginType.class, BaseMessages.getString( JobMeta.class, "JobCategory.Category.Deprecated" ) ); for ( PluginInterface p : deprecatedJobEntries ) { String[] ids = p.getIds(); if ( !ArrayUtils.isEmpty( ids ) && ids[0].equals( this.entry != null ? this.entry.getPluginId() : "" ) ) { this.isDeprecated = true; this.suggestion = registry.findPluginWithId( JobEntryPluginType.class, this.entry.getPluginId() ) != null ? registry.findPluginWithId( JobEntryPluginType.class, this.entry.getPluginId() ).getSuggestion() : ""; break; } } } }