Tabnine Logo
Reflections.evalEnum
Code IndexAdd Tabnine to your IDE (free)

How to use
evalEnum
method
in
com.palantir.ptoss.util.Reflections

Best Java code snippets using com.palantir.ptoss.util.Reflections.evalEnum (Showing top 3 results out of 315)

origin: palantir/Cinch

/**
 * Resolves a string reference, as specified in the <code>on</code> parameter of
 * a {@link Bound} annotation to an Enum object in this runtime.
 * @param on <code>on</code> parameter from a {@link Bound} annotation.
 * @param model
 * @return the resolved object
 * @throws IllegalArgumentException if the referenced object can't be found.
 */
public static ModelUpdate findOnObject(final String on, final BindableModel model) {
  ModelUpdate onObject = null;
  if (!isNullOrBlank(on)) {
    final List<Class<?>> updateClasses = findModelUpdateClass(model);
    for (Class<?> updateClass : updateClasses) {
      try {
        onObject = (ModelUpdate)Reflections.evalEnum(updateClass, on);
        return onObject;
      } catch (IllegalArgumentException e) {
        // swallow this if we don't find the enum on one of the
        // classes, continue to next class.
      }
    }
    throw new IllegalArgumentException("could not find \"on\" parameter " + on);
  }
  return onObject;
}
origin: palantir/Cinch

  public void testEnumTypes() throws Exception {
    Object o = Reflections.evalEnum(TestEnum.class, "FOO");
    assertTrue("Object is not a ModelUpdate instance",ModelUpdate.class.isAssignableFrom(o.getClass()));

  }
}
origin: palantir/Cinch

  public static Binding bindJToggleButtonToEnum(final String value, final Class<?> enumType,
      final Mutator mutator, final AbstractButton button) {
    final Object enumValue = Reflections.evalEnum(enumType, value);
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
          mutator.set(enumValue);
        } catch (Exception ex) {
          Wiring.logger.error("exception in JToggleButton binding", ex); //$NON-NLS-1$
        }
      }
    });

    Binding binding = new Binding() {
      public <T extends Enum<?> & ModelUpdate> void update(T... changed) {
        try {
          button.setSelected(mutator.get() == enumValue);
        } catch (Exception ex) {
          Wiring.logger.error("exception in JToggleButton binding", ex); //$NON-NLS-1$
        }
      }
    };
    mutator.getModel().bind(binding);
    return binding;
  }
}
com.palantir.ptoss.utilReflectionsevalEnum

Javadoc

Looks up an Enum value by its String name.

Popular methods of Reflections

  • getAnnotatedFields
    Returns the list of fields on this class annotated with the passed Annotation
  • getAnnotatedFieldsForClassHierarchy
    Returns the list of fields on this class or any of its ancestors annotated with the passed Annotatio
  • getFieldObject
    Given an Object and a Field of a known Class type, get the field. This will return the value of the
  • getFieldsOfType
    Gets all fields from a given class that are assignable from the target class.
  • getFieldsOfTypeForClassHierarchy
    Gets all fields assignable from targetClass in the passed class's type hierarchy.
  • getParameterlessMethodsForClassHierarchy
    Returns all methods in the passed object's class hierarchy that do no not take parameters
  • getTypesOfType
    Gets all inner classes from a given class that are assignable from the target class.
  • getTypesOfTypeForClassHierarchy
    Gets all inner classes assignable from targetClass in the passed class's type hierarchy.
  • getterFunction
    Returns a Function that will read values from the named field from a passed object.
  • isClassAnnotatedForClassHierarchy
    Checks whether or not the specified Annotation exists in the passed Object's class hierarchy.
  • isFieldFinal
    Returns whether or not the given Field is final.
  • isFieldStatic
    Returns whether or not the given Field is static.
  • isFieldFinal,
  • isFieldStatic,
  • isMethodPublic,
  • visitClassHierarchy

Popular in Java

  • Reading from database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • runOnUiThread (Activity)
  • getSystemService (Context)
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now