Java Code Examples for java.lang.reflect.Field#equals()
The following examples show how to use
java.lang.reflect.Field#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JClassDependency.java From baratine with GNU General Public License v2.0 | 6 votes |
public int compare(Field a, Field b) { if (a == b) return 0; else if (a == null) return -1; else if (b == null) return 1; else if (a.equals(b)) return 0; int cmp = a.getName().compareTo(b.getName()); if (cmp != 0) return cmp; cmp = a.getDeclaringClass().getName().compareTo(b.getDeclaringClass().getName()); if (cmp != 0) return cmp; return a.getType().getName().compareTo(b.getType().getName()); }
Example 2
Source File: ClassTypeHelper.java From jrpip with Apache License 2.0 | 5 votes |
public int compare(Field o1, Field o2) { if (o1.equals(o2)) { return 0; } return ClassTypeHelper.isPrintableClass(o1.getType()) ? -1 : 1; }
Example 3
Source File: WebTesterTestNGListener.java From webtester-core with Apache License 2.0 | 5 votes |
/** * Because every method have the same browser instances, there would be duplicates of all Browsers * which would result in an `NoUniquePrimaryBrowserException`. This method compares the given * field with all existing classBrowserFields and returns true if it is no duplicate of an existing field. * * @param field the given browser candidate. * @return true in case that field is no duplicate, false if it is a duplicate. */ private boolean fieldIsNoDuplicateOfAnExistingClassBrowserField(Field field) { boolean isNoDuplicate = true; for (Field classBrowserField : classBrowserFields) { if (classBrowserField.equals(field)) { isNoDuplicate = false; } } return isNoDuplicate; }
Example 4
Source File: BeanUtil.java From mango with Apache License 2.0 | 5 votes |
private static int indexOfFields(@Nullable Field field, List<Field> fields) { if (field != null) { for (int i = 0; i < fields.size(); i++) { if (field.equals(fields.get(i))) { return i; } } } return MISS_FLAG; }
Example 5
Source File: DeepLearning.java From h2o-2 with Apache License 2.0 | 4 votes |
/** * Train a Deep Learning model, assumes that all members are populated * If checkpoint == null, then start training a new model, otherwise continue from a checkpoint */ private void buildModel() { DeepLearningModel cp = null; if (checkpoint == null) { cp = initModel(); cp.start_training(null); } else { final DeepLearningModel previous = UKV.get(checkpoint); if (previous == null) throw new IllegalArgumentException("Checkpoint not found."); Log.info("Resuming from checkpoint."); if (n_folds != 0) { throw new UnsupportedOperationException("n_folds must be 0: Cross-validation is not supported during checkpoint restarts."); } else { ((ValidatedJob)previous.job()).xval_models = null; //remove existing cross-validation keys after checkpoint restart } if (source == null || (previous.model_info().get_params().source != null && !Arrays.equals(source._key._kb, previous.model_info().get_params().source._key._kb))) { throw new IllegalArgumentException("source must be the same as for the checkpointed model."); } autoencoder = previous.model_info().get_params().autoencoder; if (!autoencoder && (response == null || !source.names()[source.find(response)].equals(previous.responseName()))) { throw new IllegalArgumentException("response must be the same as for the checkpointed model."); } // if (!autoencoder && (response == null || !Arrays.equals(response._key._kb, previous.model_info().get_params().response._key._kb))) { // throw new IllegalArgumentException("response must be the same as for the checkpointed model."); // } if (Utils.difference(ignored_cols, previous.model_info().get_params().ignored_cols).length != 0 || Utils.difference(previous.model_info().get_params().ignored_cols, ignored_cols).length != 0) { ignored_cols = previous.model_info().get_params().ignored_cols; Log.warn("Automatically re-using ignored_cols from the checkpointed model."); } if ((validation == null) == (previous._validationKey != null) || (validation != null && validation._key != null && previous._validationKey != null && !Arrays.equals(validation._key._kb, previous._validationKey._kb))) { throw new IllegalArgumentException("validation must be the same as for the checkpointed model."); } if (classification != previous.model_info().get_params().classification) { Log.warn("Automatically switching to " + ((classification=!classification) ? "classification" : "regression") + " (same as the checkpointed model)."); } epochs += previous.epoch_counter; //add new epochs to existing model Log.info("Adding " + String.format("%.3f", previous.epoch_counter) + " epochs from the checkpointed model."); try { final DataInfo dataInfo = prepareDataInfo(); cp = new DeepLearningModel(previous, destination_key, job_key, dataInfo); cp.write_lock(self()); cp.start_training(previous); assert(state==JobState.RUNNING); final DeepLearning A = cp.model_info().get_params(); Object B = this; for (Field fA : A.getClass().getDeclaredFields()) { if (Utils.contains(cp_modifiable, fA.getName())) { if (!expert_mode && Utils.contains(expert_options, fA.getName())) continue; for (Field fB : B.getClass().getDeclaredFields()) { if (fA.equals(fB)) { try { if (fB.get(B) == null || fA.get(A) == null || !fA.get(A).toString().equals(fB.get(B).toString())) { // if either of the two parameters is null, skip the toString() if (fA.get(A) == null && fB.get(B) == null) continue; //if both parameters are null, we don't need to do anything Log.info("Applying user-requested modification of '" + fA.getName() + "': " + fA.get(A) + " -> " + fB.get(B)); fA.set(A, fB.get(B)); } } catch (IllegalAccessException e) { e.printStackTrace(); } } } } } if (A.n_folds != 0) { Log.warn("Disabling cross-validation: Not supported when resuming training from a checkpoint."); A.n_folds = 0; } cp.update(self()); } finally { if (cp != null) cp.unlock(self()); } } trainModel(cp); cp.stop_training(); }