Example usage for java.lang Enum valueOf

List of usage examples for java.lang Enum valueOf

Introduction

In this page you can find the example usage for java.lang Enum valueOf.

Prototype

public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name) 

Source Link

Document

Returns the enum constant of the specified enum type with the specified name.

Usage

From source file:com.bekwam.resignator.ResignatorAppMainViewController.java

@FXML
public void initialize() {

    try {//from   w w  w  .  ja  v a2 s  .com

        miHelp.setAccelerator(KeyCombination.keyCombination("F1"));

        cbType.getItems().add(SigningArgumentsType.JAR);
        cbType.getItems().add(SigningArgumentsType.FOLDER);

        cbType.getSelectionModel().select(SigningArgumentsType.JAR);

        cbType.setConverter(new StringConverter<SigningArgumentsType>() {

            @Override
            public String toString(SigningArgumentsType type) {
                return StringUtils.capitalize(StringUtils.lowerCase(String.valueOf(type)));
            }

            @Override
            public SigningArgumentsType fromString(String type) {
                return Enum.valueOf(SigningArgumentsType.class, StringUtils.upperCase(type));
            }

        });

        activeConfiguration.activeProfileProperty().bindBidirectional(activeProfile.profileNameProperty());
        tfSourceFile.textProperty().bindBidirectional(activeProfile.sourceFileFileNameProperty());
        tfTargetFile.textProperty().bindBidirectional(activeProfile.targetFileFileNameProperty());
        ckReplace.selectedProperty().bindBidirectional(activeProfile.replaceSignaturesProperty());
        cbType.valueProperty().bindBidirectional(activeProfile.argsTypeProperty());

        miSave.disableProperty().bind(needsSave.not());

        tfSourceFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener));
        tfTargetFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener));
        ckReplace.selectedProperty().addListener(new WeakInvalidationListener(needsSaveListener));
        cbType.valueProperty().addListener(new WeakInvalidationListener(needsSaveListener));

        lblSource.setText(SOURCE_LABEL_JAR);
        lblTarget.setText(TARGET_LABEL_JAR);
        cbType.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> {
            if (new_v == SigningArgumentsType.FOLDER) {
                if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_FOLDER)) {
                    lblSource.setText(SOURCE_LABEL_FOLDER);
                }
                if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_FOLDER)) {
                    lblTarget.setText(TARGET_LABEL_FOLDER);
                }
            } else {
                if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_JAR)) {
                    lblSource.setText(SOURCE_LABEL_JAR);
                }
                if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_JAR)) {
                    lblTarget.setText(TARGET_LABEL_JAR);
                }
            }
        });

        lvProfiles.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> {

            if (new_v == null) { // coming from clearSelection or sort
                return;
            }

            if (needsSave.getValue()) {

                Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Discard unsaved profile?");
                alert.setHeaderText("Unsaved profile");
                Optional<ButtonType> response = alert.showAndWait();
                if (!response.isPresent() || response.get() != ButtonType.OK) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("[SELECT] discard canceled");
                    }
                    return;
                }
            }

            if (logger.isDebugEnabled()) {
                logger.debug("[SELECT] nv={}", new_v);
            }
            doLoadProfile(new_v);
        });

        lvProfiles.setCellFactory(TextFieldListCell.forListView());

        Task<Void> t = new Task<Void>() {

            @Override
            protected Void call() throws Exception {

                updateMessage("Loading configuration");
                configurationDS.loadConfiguration();

                if (!configurationDS.isSecured()) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("[CALL] config not secured; getting password");
                    }
                    NewPasswordController npc = newPasswordControllerProvider.get();

                    if (logger.isDebugEnabled()) {
                        logger.debug("[INIT TASK] npc id={}", npc.hashCode());
                    }

                    Platform.runLater(() -> {
                        try {
                            npc.showAndWait();
                        } catch (Exception exc) {
                            logger.error("error showing npc", exc);
                        }
                    });

                    synchronized (npc) {
                        try {
                            npc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password
                        } catch (InterruptedException exc) {
                            logger.error("new password operation interrupted", exc);
                        }
                    }

                    if (logger.isDebugEnabled()) {
                        logger.debug("[INIT TASK] npc={}", npc.getHashedPassword());
                    }

                    if (StringUtils.isNotEmpty(npc.getHashedPassword())) {

                        activeConfiguration.setHashedPassword(npc.getHashedPassword());
                        activeConfiguration.setUnhashedPassword(npc.getUnhashedPassword());
                        activeConfiguration.setLastUpdatedDateTime(LocalDateTime.now());
                        configurationDS.saveConfiguration();

                        configurationDS.loadConfiguration();
                        configurationDS.decrypt(activeConfiguration.getUnhashedPassword());

                    } else {

                        Platform.runLater(() -> {
                            Alert noPassword = new Alert(Alert.AlertType.INFORMATION,
                                    "You'll need to provide a password to save your keystore credentials.");
                            noPassword.showAndWait();
                        });

                        return null;
                    }
                } else {

                    PasswordController pc = passwordControllerProvider.get();

                    Platform.runLater(() -> {
                        try {
                            pc.showAndWait();
                        } catch (Exception exc) {
                            logger.error("error showing pc", exc);
                        }
                    });

                    synchronized (pc) {
                        try {
                            pc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password
                        } catch (InterruptedException exc) {
                            logger.error("password operation interrupted", exc);
                        }
                    }

                    Platform.runLater(() -> {

                        if (pc.getStage().isShowing()) { // ended in timeout timeout
                            pc.getStage().hide();
                        }

                        if (pc.wasCancelled() || pc.wasReset() || !pc.doesPasswordMatch()) {

                            if (logger.isDebugEnabled()) {
                                logger.debug("[INIT TASK] was cancelled or the number of retries was exceeded");
                            }

                            String msg = "";
                            if (pc.wasCancelled()) {
                                msg = "You must provide a password to the datastore. Exitting...";
                            } else if (pc.wasReset()) {
                                msg = "Data file removed. Exitting...";
                            } else {
                                msg = "Exceeded maximum number of retries. Exitting...";
                            }

                            Alert alert = new Alert(Alert.AlertType.WARNING, msg);
                            alert.setOnCloseRequest((evt) -> {
                                Platform.exit();
                                System.exit(1);
                            });
                            alert.showAndWait();

                        } else {

                            //
                            // save password for later decryption ops
                            //

                            activeConfiguration.setUnhashedPassword(pc.getPassword());
                            configurationDS.decrypt(activeConfiguration.getUnhashedPassword());

                            //
                            // init profileBrowser
                            //
                            if (logger.isDebugEnabled()) {
                                logger.debug("[INIT TASK] loading profiles from source");
                            }

                            long startTimeMillis = System.currentTimeMillis();

                            final List<String> profileNames = configurationDS.getProfiles().stream()
                                    .map(Profile::getProfileName).sorted((o1, o2) -> o1.compareToIgnoreCase(o2))
                                    .collect(Collectors.toList());

                            final List<String> recentProfiles = configurationDS.getRecentProfileNames();

                            if (logger.isDebugEnabled()) {
                                logger.debug("[INIT TASK] loading profiles into UI");
                            }

                            lvProfiles.setItems(FXCollections.observableArrayList(profileNames));

                            if (CollectionUtils.isNotEmpty(recentProfiles)) {
                                mRecentProfiles.getItems().clear();
                                mRecentProfiles.getItems().addAll(
                                        FXCollections.observableArrayList(recentProfiles.stream().map((s) -> {
                                            MenuItem mi = new MenuItem(s);
                                            mi.setOnAction(recentProfileLoadHandler);
                                            return mi;
                                        }).collect(Collectors.toList())));
                            }

                            //
                            // #31 preload the last active profile
                            //
                            if (StringUtils.isNotEmpty(activeConfiguration.getActiveProfile())) {

                                if (logger.isDebugEnabled()) {
                                    logger.debug("[INIT TASK] preloading last active profile={}",
                                            activeConfiguration.getActiveProfile());
                                }
                                doLoadProfile(activeConfiguration.getActiveProfile());
                            }

                            long endTimeMillis = System.currentTimeMillis();

                            if (logger.isDebugEnabled()) {
                                logger.debug("[INIT TASK] loading profiles took {} ms",
                                        (endTimeMillis - startTimeMillis));
                            }
                        }
                    });
                }

                return null;
            }

            @Override
            protected void succeeded() {
                super.succeeded();
                updateMessage("");
                lblStatus.textProperty().unbind();
            }

            @Override
            protected void cancelled() {
                super.cancelled();
                logger.error("task cancelled", getException());
                updateMessage("");
                lblStatus.textProperty().unbind();
            }

            @Override
            protected void failed() {
                super.failed();
                logger.error("task failed", getException());
                updateMessage("");
                lblStatus.textProperty().unbind();
            }
        };

        lblStatus.textProperty().bind(t.messageProperty());

        new Thread(t).start();

    } catch (Exception exc) {

        logger.error("can't load configuration", exc);

        String msg = "Verify that the user has access to the directory '" + configFile + "' under "
                + System.getProperty("user.home") + ".";

        Alert alert = new Alert(Alert.AlertType.ERROR, msg);
        alert.setHeaderText("Can't load config file");
        alert.showAndWait();

        Platform.exit();
    }
}

From source file:com.netflix.astyanax.thrift.ThriftUtils.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private static Object populateObject(Object obj, Map<String, Object> map) throws Exception {
    org.apache.thrift.TBase entity = (org.apache.thrift.TBase) obj;
    Field field = entity.getClass().getDeclaredField("metaDataMap");
    Map<org.apache.thrift.TFieldIdEnum, org.apache.thrift.meta_data.FieldMetaData> fields = (Map<org.apache.thrift.TFieldIdEnum, FieldMetaData>) field
            .get(entity);// w  ww . j  av a2s . co  m

    for (Entry<TFieldIdEnum, FieldMetaData> f : fields.entrySet()) {
        Object value = map.get(f.getKey().getFieldName());
        if (value != null) {
            ThriftTypes type = ThriftTypes.values()[f.getValue().valueMetaData.type];

            switch (type) {
            case VOID:
                break;
            case BYTE:
            case BOOL:
            case DOUBLE:
            case I16:
            case I32:
            case I64:
            case STRING:
                try {
                    entity.setFieldValue(f.getKey(), valueForBasicType(value, f.getValue().valueMetaData.type));
                } catch (ClassCastException e) {
                    if (e.getMessage().contains(ByteBuffer.class.getCanonicalName())) {
                        entity.setFieldValue(f.getKey(), ByteBuffer.wrap(Base64.decodeBase64((String) value)));
                    } else {
                        throw e;
                    }
                }
                break;
            case ENUM: {
                org.apache.thrift.meta_data.EnumMetaData meta = (org.apache.thrift.meta_data.EnumMetaData) f
                        .getValue().valueMetaData;
                Object e = meta.enumClass;
                entity.setFieldValue(f.getKey(), Enum.valueOf((Class<Enum>) e, (String) value));
                break;
            }
            case MAP: {
                org.apache.thrift.meta_data.MapMetaData meta = (org.apache.thrift.meta_data.MapMetaData) f
                        .getValue().valueMetaData;
                if (!meta.keyMetaData.isStruct() && !meta.keyMetaData.isContainer()) {
                    Map<Object, Object> childMap = (Map<Object, Object>) value;
                    Map<Object, Object> childEntityMap = Maps.newHashMap();
                    entity.setFieldValue(f.getKey(), childEntityMap);

                    if (!meta.keyMetaData.isStruct() && !meta.keyMetaData.isContainer()) {
                        for (Entry<Object, Object> entry : childMap.entrySet()) {
                            Object childKey = valueForBasicType(entry.getKey(), meta.keyMetaData.type);
                            Object childValue = valueForBasicType(entry.getValue(), meta.valueMetaData.type);
                            childEntityMap.put(childKey, childValue);
                        }
                    }
                } else {
                    LOG.error(String.format("Unable to serializer field '%s' key type '%s' not supported",
                            f.getKey().getFieldName(), meta.keyMetaData.getTypedefName()));
                }
                break;
            }
            case LIST: {
                Map<String, Object> childMap = (Map<String, Object>) value;
                org.apache.thrift.meta_data.ListMetaData listMeta = (org.apache.thrift.meta_data.ListMetaData) f
                        .getValue().valueMetaData;

                // Create an empty list and attach to the parent entity
                List<Object> childList = Lists.newArrayList();
                entity.setFieldValue(f.getKey(), childList);

                if (listMeta.elemMetaData instanceof org.apache.thrift.meta_data.StructMetaData) {
                    org.apache.thrift.meta_data.StructMetaData structMeta = (org.apache.thrift.meta_data.StructMetaData) listMeta.elemMetaData;
                    for (Entry<String, Object> childElement : childMap.entrySet()) {
                        org.apache.thrift.TBase childEntity = structMeta.structClass.newInstance();
                        populateObject(childEntity, (Map<String, Object>) childElement.getValue());
                        childList.add(childEntity);
                    }
                }
                break;
            }
            case STRUCT: {
                break;
            }
            case SET:
            default:
                LOG.error("Unhandled value : " + f.getKey().getFieldName() + " " + type);
                break;
            }
        }
    }
    return entity;
}

From source file:net.bulletin.pdi.xero.step.XeroGetStep.java

private OAuthMessage openXero(XeroGetStepMeta meta) throws KettleException {

    String consumerKey = environmentSubstitute(meta.getAuthenticationConsumerKey());

    if (StringUtils.isBlank(consumerKey)) {
        throw new KettleException("the xero consumer key must be supplied");
    }/*  www  .  ja  v a 2s  .co  m*/

    logBasic("will use xero consumer key; " + Helpers.obfuscateAuthenticationDetailForLog(consumerKey));

    String key = readXeroKey(meta);
    logBasic("will use xero key; " + Helpers.obfuscateAuthenticationDetailForLog(key));

    String url = createXeroUrl(meta);
    String ifModifiedSinceHeaderValue = createIfModifiedSinceHeaderValue(meta);

    OAuthServiceProvider serviceProvider = new OAuthServiceProvider(null, null, null);
    OAuthConsumer consumer = new OAuthConsumer(null, consumerKey, null, serviceProvider);
    consumer.setProperty(RSA_SHA1.PRIVATE_KEY, key);

    consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.RSA_SHA1);
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    accessor.accessToken = consumerKey;

    try {
        OAuthMessage request = accessor.newRequestMessage("GET", createXeroUrl(meta),
                new ArrayList<Map.Entry>(), null);

        OAuthClient client = new OAuthClient(new URLConnectionClient());
        request.getHeaders().add(new OAuth.Parameter("Accept", "text/xml"));

        if (StringUtils.isNotBlank(ifModifiedSinceHeaderValue)) {
            request.getHeaders().add(new OAuth.Parameter("If-Modified-Since", ifModifiedSinceHeaderValue));
            logBasic("will use 'If-Modified-Since' header of; " + ifModifiedSinceHeaderValue);
        }

        Object ps = accessor.consumer.getProperty(OAuthClient.PARAMETER_STYLE);
        ParameterStyle style = (ps == null) ? ParameterStyle.BODY
                : Enum.valueOf(ParameterStyle.class, ps.toString());

        OAuthMessage result = client.invoke(request, style);
        logBasic("did open xero connection to; " + url);
        return result;

    } catch (OAuthProblemException e) {
        // http://developer.xero.com/documentation/getting-started/http-response-codes/
        throw new KettleException("error has arisen communicating with xero api at; " + meta.getUrl() + " ("
                + e.getHttpStatusCode() + ")", e);
    } catch (IOException e) {
        throw new KettleException("error has arisen communicating with xero api at; " + meta.getUrl(), e);
    } catch (OAuthException e) {
        throw new KettleException("error has arisen communicating with xero api at; " + meta.getUrl(), e);
    } catch (URISyntaxException use) {
        throw new KettleException("the supplied URI syntax is malformed; " + meta.getUrl(), use);
    }

}

From source file:io.coala.config.AbstractPropertyGetter.java

/**
 * @param enumType//from w  w w.  j  ava 2s .c o m
 * @return
 * @throws CoalaException if value was not configured nor any default was
 *             set
 */
public <E extends Enum<E>> E getEnum(final Class<E> enumType) throws CoalaException {
    if (enumType == null)
        throw CoalaExceptionFactory.VALUE_NOT_SET.createRuntime("enumType");

    final String value = get();
    try {
        return Enum.valueOf(enumType, value);
    } catch (final Throwable e) {
        throw CoalaExceptionFactory.UNMARSHAL_FAILED.create(e, value,
                enumType != null ? defaultValue.getClass() : Enum.class);
    }
}

From source file:com.sf.ddao.orm.RSMapperFactoryRegistry.java

public static RowMapperFactory getScalarMapper(final Type itemType, final int idx, boolean req) {
    if (itemType == String.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getString(idx);
            }//  w  w  w .  jav  a 2  s  .c om
        };
    }
    if (itemType == Integer.class || itemType == Integer.TYPE) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getInt(idx);
            }
        };
    }
    if (itemType == URL.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getURL(idx);
            }
        };
    }
    if (itemType == BigInteger.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                final BigDecimal res = rs.getBigDecimal(idx);
                return res == null ? null : res.toBigInteger();
            }
        };
    }
    if (itemType == BigDecimal.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getBigDecimal(idx);
            }
        };
    }
    if (itemType == InputStream.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getBinaryStream(idx);
            }
        };
    }
    if (itemType == Boolean.class || itemType == Boolean.TYPE) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getBoolean(idx);
            }
        };
    }
    if (itemType == Blob.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getBlob(idx);
            }
        };
    }
    if (itemType == java.sql.Date.class || itemType == java.util.Date.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getTimestamp(idx);
            }
        };
    }
    if (itemType instanceof Class) {
        final Class itemClass = (Class) itemType;
        final ColumnMapper columnMapper = ColumnMapperRegistry.lookup(itemClass);
        if (columnMapper != null) {
            return new ScalarRMF() {
                public Object map(ResultSet rs) throws SQLException {
                    return columnMapper.map(rs, idx);
                }
            };
        }
        final Converter converter = ConvertUtils.lookup(itemClass);
        if (converter != null) {
            return new ScalarRMF() {
                public Object map(ResultSet rs) throws SQLException {
                    String s = rs.getString(idx);
                    if (s == null) {
                        return null;
                    }
                    return converter.convert(itemClass, s);
                }
            };
        }
        if (Enum.class.isAssignableFrom((Class<?>) itemType)) {
            return new ScalarRMF() {
                public Object map(ResultSet rs) throws SQLException {
                    String s = rs.getString(idx);
                    if (s == null) {
                        return null;
                    }
                    //noinspection unchecked
                    return Enum.valueOf((Class<Enum>) itemType, s);
                }
            };
        }
    }
    if (req) {
        throw new IllegalArgumentException("no mapping defined for " + itemType);
    }
    return null;
}

From source file:org.openspaces.rest.utils.ControllerUtils.java

public static Object convertPropertyToPrimitiveType(String object, Class type, String propKey) {
    if (type.equals(Long.class) || type.equals(Long.TYPE))
        return Long.valueOf(object);

    if (type.equals(Boolean.class) || type.equals(Boolean.TYPE))
        return Boolean.valueOf(object);

    if (type.equals(Integer.class) || type.equals(Integer.TYPE))
        return Integer.valueOf(object);

    if (type.equals(Byte.class) || type.equals(Byte.TYPE))
        return Byte.valueOf(object);

    if (type.equals(Short.class) || type.equals(Short.TYPE))
        return Short.valueOf(object);

    if (type.equals(Float.class) || type.equals(Float.TYPE))
        return Float.valueOf(object);

    if (type.equals(Double.class) || type.equals(Double.TYPE))
        return Double.valueOf(object);

    if (type.isEnum())
        return Enum.valueOf(type, object);

    if (type.equals(String.class) || type.equals(Object.class))
        return String.valueOf(object);

    if (type.equals(java.util.Date.class)) {
        try {//from   w  w w .  j a v  a  2 s .  c  o m
            return simpleDateFormat.parse(object);
        } catch (ParseException e) {
            throw new RestException(
                    "Unable to parse date [" + object + "]. Make sure it matches the format: " + date_format);
        }
    }

    //unknown type
    throw new UnsupportedTypeException("Non primitive type when converting property [" + propKey + "]:" + type);
}

From source file:org.icgc.dcc.portal.resource.Resource.java

protected static <E extends Enum<E>> boolean isValidEnum(Class<E> enumClass, String enumName) {
    if (enumName == null) {
        return false;
    }//from  w w  w.j a  va2s  . com
    try {
        Enum.valueOf(enumClass, enumName);
        return true;
    } catch (final IllegalArgumentException ex) {
        return false;
    }
}

From source file:com.clover.sdk.GenericClient.java

/**
 * Generic method that returns a list of T items. Replacement for the "extract" methods which dealt with a list of Enums.
 *///from w  ww. j av a 2 s . co m
public <T extends Enum<T>> java.util.List<T> extractListEnum(String name, Class<T> clazz) {
    if (getJSONObject().isNull(name)) {
        return null;
    }

    org.json.JSONObject elementsContainer = getJSONObject().optJSONObject(name);
    org.json.JSONArray itemArray = elementsContainer.optJSONArray("elements");
    java.util.List<T> itemList = new java.util.ArrayList<T>(itemArray.length());
    for (int i = 0; i < itemArray.length(); i++) {
        String enumString = itemArray.optString(i, null);
        if (enumString == null) {
            continue;
        }
        T item;
        try {
            item = Enum.valueOf(clazz, enumString);
        } catch (Exception e) {
            e.printStackTrace();
            continue;
        }
        itemList.add(item);
    }

    return java.util.Collections.unmodifiableList(itemList);
}

From source file:at.beris.jarcommander.helper.ModelViewController.java

public void setModelPropertyValue(String propertyName, Object newValue) {
    try {//from   w  w  w. j  a  v  a  2 s . c  o  m
        Class modelPropertyType = model.getClass().getDeclaredField(propertyName).getType();
        Method modelPropertySetter = getPropertySetter(model, propertyName, modelPropertyType);
        Method modelPropertyGetter = getPropertyGetter(model, propertyName);

        Object oldValue = modelPropertyGetter.invoke(model);

        if ((oldValue != null && newValue == null) || (oldValue == null && newValue != null)
                || (!StringUtils.equals(oldValue.toString(), newValue.toString()))) {
            if (Arrays.asList(new String[] { "Integer", "int" }).contains(modelPropertyType.getSimpleName())) {
                modelPropertySetter.invoke(model, Integer.valueOf((String) newValue));
            } else if (modelPropertyType.getSuperclass().getSimpleName().equals("Enum")) {
                modelPropertySetter.invoke(model, Enum.valueOf(
                        (Class<? extends Enum>) Class.forName(modelPropertyType.getName()), (String) newValue));
            } else if (modelPropertyType.getSimpleName().equals("char[]")) {
                modelPropertySetter.invoke(model, ((String) newValue).toCharArray());
            } else {
                modelPropertySetter.invoke(model, modelPropertyType.cast(newValue));
            }
        }
    } catch (IllegalAccessException e) {
        logException(e);
    } catch (InvocationTargetException e) {
        logException(e);
    } catch (NoSuchFieldException e) {
        logException(e);
    } catch (ClassNotFoundException e) {
        logException(e);
    }
}

From source file:org.reficio.cougar.core.FrameBuilder.java

public Ack ack() {
    String value = getHeaderValue(ACK);
    if (StringUtils.isNotBlank(value)) {
        validateEnumValue(Ack.class, value.toUpperCase());
        return Enum.valueOf(Ack.class, value.toUpperCase());
    } else {/*from www  . j  av  a2 s  .  co m*/
        return null;
    }
}