List of usage examples for java.lang Enum name
String name
To view the source code for java.lang Enum name.
Click Source Link
From source file:com.android.aft.AFNotificator.AFNotificatorReceiver.java
public void connect(Enum<?> e) { dbg.d("Connect to event " + e.name()); AFNotificatorEvent event = getEventByEnum(e); if (event == null) throw new AFNotificatorException( "Cannot find connect event parameter '" + e.name() + "' in the list of " + mName + " events"); try {//from w ww.j a va 2 s. c o m Method method = mTarget.getClass().getMethod(event.name, event.args); mMethods.put(event.name, method); return; } catch (Exception ex) { dbg.e("Cannot find method '" + event.name + "' to connect on the target " + mTarget, ex); dbg.e("Potential method are:"); for (Method m : mTarget.getClass().getMethods()) { if (m.getName().equals(event.name)) dbg.e("- " + m); } throw new AFNotificatorException("Cannot connect event '" + event.name + "' on target " + mTarget); } }
From source file:edu.duke.cabig.c3pr.utils.web.propertyeditors.EnumByNameEditor.java
@Override @SuppressWarnings("unchecked") public String getAsText() { Enum<E> v = (Enum<E>) getValue(); if (v == null) { return null; } else {/*from w w w .j av a 2s .co m*/ return v.name(); } }
From source file:com.evolveum.midpoint.repo.sql.query2.restriction.Restriction.java
protected String nameOf(Enum e) { return e.getClass().getName() + "." + e.name(); }
From source file:org.netxilia.api.impl.format.EnumerationFormatter.java
@SuppressWarnings("unchecked") public EnumerationFormatter(StyleDefinition definition) { super(definition); values = new ArrayList<NamedValue>(); // TODO allow different attributes for names and values String enumClassName = getDefinition().getAttribute(ATT_ENUM_CLASS); if (enumClassName == null) { throw new IllegalArgumentException( "Enum Class was not defined for the enum formatter: " + definition.getName()); }/* w w w . j a v a2 s.com*/ try { enumClass = (Class<Enum<?>>) Class.forName(enumClassName); } catch (ClassNotFoundException ex) { throw new IllegalArgumentException("Unknown class:" + enumClassName); } String enumValueProperty = getDefinition().getAttribute(ATT_ENUM_VALUE); for (Enum<?> enumItem : enumClass.getEnumConstants()) { values.add(new NamedValue(enumItem.name(), enumValue(enumValueProperty, enumItem))); } }
From source file:org.apache.hive.spark.counter.SparkCounters.java
public void createCounter(String groupName, Enum<?> key) { createCounter(groupName, key.name(), 0L); }
From source file:io.gravitee.management.rest.mapper.ObjectMapperResolver.java
public ObjectMapperResolver() { mapper = new GraviteeMapper(); SimpleModule module = new SimpleModule(); module.setDeserializerModifier(new BeanDeserializerModifier() { @Override//from w ww. j av a 2s . c o m public JsonDeserializer<Enum> modifyEnumDeserializer(DeserializationConfig config, final JavaType type, BeanDescription beanDesc, final JsonDeserializer<?> deserializer) { return new JsonDeserializer<Enum>() { @Override public Enum deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Class<? extends Enum> rawClass = (Class<Enum<?>>) type.getRawClass(); return Enum.valueOf(rawClass, jp.getValueAsString().toUpperCase()); } }; } }); module.addSerializer(Enum.class, new StdSerializer<Enum>(Enum.class) { @Override public void serialize(Enum value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(value.name().toLowerCase()); } }); mapper.registerModule(module); }
From source file:org.n52.sos.service.it.MockHttpClient.java
@Override public MockHttpClient query(String key, Enum<?> value) { return query(key, value.name()); }
From source file:org.beigesoft.service.persist.xml.ASrvSaveXmlBase.java
public String toEnumNameOrNull(Enum<?> value) { if (value == null) { return "<Null/>"; }//from www .j ava 2 s . c o m return value.name(); }
From source file:org.apache.empire.spring.EmpireReader.java
@Override protected void getBeanProperty(Object bean, String property, Object value) { try {//from ww w . ja v a 2 s. c om if (bean == null) throw new InvalidArgumentException("bean", bean); if (StringUtils.isEmpty(property)) throw new InvalidArgumentException("property", property); // Get descriptor PropertyDescriptor descriptor = BeanUtilsBean.getInstance().getPropertyUtils() .getPropertyDescriptor(bean, property); if (descriptor == null) { return; // Skip this property setter } // Check enum Class<?> type = descriptor.getPropertyType(); if (type.isEnum()) { // Enum<?> ev = Enum.valueOf(type, value); boolean found = false; Enum<?>[] items = (Enum[]) type.getEnumConstants(); for (int i = 0; i < items.length; i++) { Enum<?> item = items[i]; if (ObjectUtils.compareEqual(item.name(), value)) { value = item; found = true; break; } } // Enumeration value not found if (!found) throw new ItemNotFoundException(value); } // Set Property Value if (value != null) { // Bean utils will convert if necessary BeanUtils.setProperty(bean, property, value); } else { // Don't convert, just set PropertyUtils.setProperty(bean, property, null); } } catch (IllegalAccessException e) { log.error(bean.getClass().getName() + ": unable to set property '" + property + "'"); throw new BeanPropertySetException(bean, property, e); } catch (InvocationTargetException e) { log.error(bean.getClass().getName() + ": unable to set property '" + property + "'"); throw new BeanPropertySetException(bean, property, e); } catch (NoSuchMethodException e) { log.error(bean.getClass().getName() + ": unable to set property '" + property + "'"); throw new BeanPropertySetException(bean, property, e); } catch (NullPointerException e) { log.error(bean.getClass().getName() + ": unable to set property '" + property + "'"); throw new BeanPropertySetException(bean, property, e); } }
From source file:org.n52.sos.service.it.MockHttpClient.java
@Override public MockHttpClient query(Enum<?> key, String value) { return query(key.name(), value); }