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:org.waarp.common.json.JsonHandler.java
/** * /*from w ww .j av a 2 s. co m*/ * @param node * @param field * @param defValue * @return the Boolean if the field exists, else defValue */ public final static Boolean getValue(ObjectNode node, Enum<?> field, boolean defValue) { return node.path(field.name()).asBoolean(defValue); }
From source file:org.waarp.common.json.JsonHandler.java
/** * /* w w w . j a v a 2 s . com*/ * @param node * @param field * @param defValue * @return the String if the field exists, else defValue */ public final static String getValue(ObjectNode node, Enum<?> field, String defValue) { return getValue(node, field.name(), defValue); }
From source file:org.waarp.common.json.JsonHandler.java
/** * // w w w . j a v a 2 s. c o m * @param node * @param field * @param defValue * @return the byte array if the field exists, else defValue */ public final static byte[] getValue(ObjectNode node, Enum<?> field, byte[] defValue) { return getValue(node, field.name(), defValue); }
From source file:org.batoo.jpa.jdbc.ValueConverter.java
/** * convert java objects to jdbc friendly * /*ww w . j ava 2s.c om*/ * @param value * jdbc raw value * @param javaType * type of value * @param temporalType * temporal type * @param enumType * enum type * @param lob * is Lob * @return jdbc friendly value * @since 2.0.1 */ public static Object toJdbc(Object value, Class<?> javaType, TemporalType temporalType, EnumType enumType, boolean lob) { if (value == null) { return null; } if (temporalType != null) { switch (temporalType) { case DATE: if (value instanceof java.sql.Date) { return value; } if (value instanceof Date) { return new java.sql.Date(((Date) value).getTime()); } return new java.sql.Date(((Calendar) value).getTimeInMillis()); case TIME: if (value instanceof java.sql.Time) { return value; } if (value instanceof Date) { return new java.sql.Time(((Date) value).getTime()); } return new java.sql.Time(((Calendar) value).getTimeInMillis()); case TIMESTAMP: if (value instanceof java.sql.Timestamp) { return value; } if (value instanceof Date) { return new java.sql.Timestamp(((Date) value).getTime()); } return new java.sql.Timestamp(((Calendar) value).getTimeInMillis()); } } if (Number.class.isAssignableFrom(javaType)) { return ReflectHelper.convertNumber((Number) value, javaType); } if (enumType != null) { final Enum<?> enumValue = (Enum<?>) value; if (enumType == EnumType.ORDINAL) { return enumValue.ordinal(); } return enumValue.name(); } if (lob) { try { if (javaType == String.class) { return new SerialClob(((String) value).toCharArray()); } else if (javaType == char[].class) { return new SerialClob((char[]) value); } else if (javaType == byte[].class) { return new SerialBlob((byte[]) value); } else { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(os); try { oos.writeObject(value); } finally { oos.close(); } return new SerialBlob(os.toByteArray()); } } catch (final Exception e) { throw new PersistenceException("Cannot set parameter", e); } } else { return value; } }
From source file:org.apache.accumulo.core.client.mapreduce.lib.util.ConfiguratorBase.java
/** * Provides a configuration key for a given feature enum, prefixed by the implementingClass * /*from www .j a v a2s . co m*/ * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param e * the enum used to provide the unique part of the configuration key * @return the configuration key * @since 1.5.0 */ protected static String enumToConfKey(Class<?> implementingClass, Enum<?> e) { return implementingClass.getSimpleName() + "." + e.getDeclaringClass().getSimpleName() + "." + StringUtils.camelize(e.name().toLowerCase()); }
From source file:gov.nih.nci.caarray.plugins.illumina.IlluminaCsvDesignHandler.java
static void validateLongField(String value, Enum header, FileValidationResult result, int lineNumber, int col) { if (!Utils.isLong(value)) { final ValidationMessage error = result.addMessage(ValidationMessage.Type.ERROR, "Expected long integral value for " + header.name() + ", but was " + value); error.setLine(lineNumber);//from w w w.ja v a 2 s . co m error.setColumn(col); } }
From source file:org.waarp.common.json.JsonHandler.java
/** * /*from w w w . j av a2 s. c o m*/ * @param node * @param field * @param value */ public final static void setValue(ObjectNode node, Enum<?> field, String value) { if (value == null || value.isEmpty()) { return; } node.put(field.name(), value); }
From source file:org.waarp.common.json.JsonHandler.java
/** * // w ww . j ava 2 s . com * @param node * @param field * @param value */ public final static void setValue(ObjectNode node, Enum<?> field, byte[] value) { if (value == null || value.length == 0) { return; } node.put(field.name(), value); }
From source file:gov.nih.nci.caarray.plugins.illumina.IlluminaCsvDesignHandler.java
static void validateIntegerField(String value, Enum header, FileValidationResult result, int lineNumber, int col) { if (!Utils.isInteger(value)) { final ValidationMessage error = result.addMessage(ValidationMessage.Type.ERROR, "Expected integer value for " + header.name() + ", but was " + value); error.setLine(lineNumber);/*from w w w . j a v a2 s .c o m*/ error.setColumn(col); } }
From source file:io.github.wysohn.triggerreactor.tools.ReflectionUtil.java
public static Map<String, Object> extractVariablesWithEnumAsString(Object e) { Map<String, Object> map = new HashMap<String, Object>(); Class<?> clazz = e.getClass(); for (Field field : getAllFields(new ArrayList<Field>(), clazz)) { field.setAccessible(true);/* www .j a va2s .c om*/ try { if (field.getClass().isEnum()) { Enum<?> enumVal = (Enum<?>) field.get(e); map.put(field.getName(), enumVal.name()); } else { map.put(field.getName(), field.get(e)); } } catch (IllegalArgumentException | IllegalAccessException e1) { e1.printStackTrace(); } } return map; }