Example usage for java.lang Boolean TYPE

List of usage examples for java.lang Boolean TYPE

Introduction

In this page you can find the example usage for java.lang Boolean TYPE.

Prototype

Class TYPE

To view the source code for java.lang Boolean TYPE.

Click Source Link

Document

The Class object representing the primitive type boolean.

Usage

From source file:org.broadleafcommerce.openadmin.server.service.persistence.module.BasicPersistenceModule.java

protected Class<?> getBasicBroadleafType(SupportedFieldType fieldType) {
    Class<?> response;//w  w w .j  a  va  2  s.  co m
    switch (fieldType) {
    case BOOLEAN:
        response = Boolean.TYPE;
        break;
    case DATE:
        response = Date.class;
        break;
    case DECIMAL:
        response = BigDecimal.class;
        break;
    case MONEY:
        response = Money.class;
        break;
    case INTEGER:
        response = Integer.TYPE;
        break;
    case UNKNOWN:
        response = null;
        break;
    default:
        response = String.class;
        break;
    }

    return response;
}

From source file:nl.strohalm.cyclos.controls.customization.fields.EditCustomFieldAction.java

@SuppressWarnings("unchecked")
public DataBinder<PaymentCustomField> getPaymentCustomFieldBinder() {
    final BeanBinder<PaymentCustomField> paymentFieldBinder = (BeanBinder<PaymentCustomField>) getBasicDataBinder(
            CustomField.Nature.PAYMENT);
    paymentFieldBinder.registerBinder("enabled", PropertyBinder.instance(Boolean.TYPE, "enabled"));
    paymentFieldBinder.registerBinder("transferType",
            PropertyBinder.instance(TransferType.class, "transferType"));
    paymentFieldBinder.registerBinder("searchAccess",
            PropertyBinder.instance(PaymentCustomField.Access.class, "searchAccess"));
    paymentFieldBinder.registerBinder("listAccess",
            PropertyBinder.instance(PaymentCustomField.Access.class, "listAccess"));
    return paymentFieldBinder;
}

From source file:com.mawujun.util.AnnotationUtils.java

/**
 * Helper method for generating a hash code for an array.
 *
 * @param componentType the component type of the array
 * @param o the array//  w ww.  j a  v a2s.  c om
 * @return a hash code for the specified array
 */
private static int arrayMemberHash(Class<?> componentType, Object o) {
    if (componentType.equals(Byte.TYPE)) {
        return Arrays.hashCode((byte[]) o);
    }
    if (componentType.equals(Short.TYPE)) {
        return Arrays.hashCode((short[]) o);
    }
    if (componentType.equals(Integer.TYPE)) {
        return Arrays.hashCode((int[]) o);
    }
    if (componentType.equals(Character.TYPE)) {
        return Arrays.hashCode((char[]) o);
    }
    if (componentType.equals(Long.TYPE)) {
        return Arrays.hashCode((long[]) o);
    }
    if (componentType.equals(Float.TYPE)) {
        return Arrays.hashCode((float[]) o);
    }
    if (componentType.equals(Double.TYPE)) {
        return Arrays.hashCode((double[]) o);
    }
    if (componentType.equals(Boolean.TYPE)) {
        return Arrays.hashCode((boolean[]) o);
    }
    return Arrays.hashCode((Object[]) o);
}

From source file:org.batoo.jpa.core.impl.model.EntityTypeImpl.java

private ConstructorAccessor enhance() {
    try {//from   w  w  w  .  ja  va2  s .  c o m
        final Class<X> enhancedClass = Enhancer.enhance(this);
        final Constructor<X> constructor = enhancedClass.getConstructor(Class.class, // type
                SessionImpl.class, // session
                Object.class, // id
                Boolean.TYPE); // initialized

        return ReflectHelper.createConstructor(constructor);
    } catch (final Exception e) {
        throw new RuntimeException("Cannot enhance class: " + this.getJavaType(), e);
    }
}

From source file:com.shazam.dataengineering.pipelinebuilder.DeploymentActionTest.java

@Test
public void writingReportShouldCreateJsonFile() throws Exception {
    DeploymentAction action = new DeploymentAction(getMockAbstractBuild(), new HashMap<S3Environment, String>(),
            new AnonymousAWSCredentials());

    Date date = new Date();

    Method method = action.getClass().getDeclaredMethod("writeReport", Date.class, String.class, Boolean.TYPE);
    method.setAccessible(true);/* ww w. ja  v a  2  s.  co  m*/

    method.invoke(action, date, "test-1234", true);

    File logFile = new File(testFolder.getRoot(), "deployment.log");
    assertTrue(logFile.exists());

    List<String> jsonContent = Files.readAllLines(logFile.toPath(), Charset.defaultCharset());
    assertEquals(1, jsonContent.size());

    JSONParser jsonParser = new JSONParser();
    JSONObject log = (JSONObject) jsonParser.parse(jsonContent.get(0));
    JSONArray deployments = (JSONArray) log.get("deployments");
    JSONObject deployment = (JSONObject) deployments.get(0);

    assertEquals(String.valueOf(date.getTime()), deployment.get("date").toString());
    assertEquals("SYSTEM", deployment.get("username").toString());
    assertEquals("true", deployment.get("status").toString());
    assertEquals("test-1234", deployment.get("pipelineId"));
}

From source file:com.github.gekoh.yagen.util.FieldInfo.java

private static List<FieldInfo> convertFields(List<FieldInfo> fields, Class baseEntity) {

    for (Field field : baseEntity.getDeclaredFields()) {
        FieldInfo fi;/*from  w ww.j  a  va 2s. com*/
        Class type = field.getType();
        String name = field.getName();
        Column column = field.getAnnotation(Column.class);
        if (field.isAnnotationPresent(Embedded.class)) {
            if (field.isAnnotationPresent(AttributeOverride.class)) {
                fi = new FieldInfo(type, name, field.getAnnotation(AttributeOverride.class));
            } else {
                fi = new FieldInfo(type, name, field.getAnnotation(AttributeOverrides.class));
            }
        } else if (field.isAnnotationPresent(Enumerated.class)) {
            fi = new FieldInfo(type, name, true, column);
        } else if (column != null && !field.isAnnotationPresent(CollectionTable.class)) {
            if (type.isPrimitive()) {
                if (type.equals(Boolean.TYPE)) {
                    type = Boolean.class;
                } else if (type.equals(Long.TYPE)) {
                    type = Long.class;
                } else if (type.equals(Integer.TYPE)) {
                    type = Integer.class;
                } else if (type.equals(Short.TYPE)) {
                    type = Short.class;
                } else if (type.equals(Byte.TYPE)) {
                    type = Byte.class;
                } else if (type.equals(Double.TYPE)) {
                    type = Double.class;
                } else if (type.equals(Float.TYPE)) {
                    type = Float.class;
                } else if (type.equals(Character.TYPE)) {
                    type = Character.class;
                }
            }
            fi = new FieldInfo(type, name, false, column);
        } else if ((field.isAnnotationPresent(ManyToOne.class) && !field.isAnnotationPresent(JoinTable.class))
                || (field.isAnnotationPresent(OneToOne.class)
                        && StringUtils.isEmpty(field.getAnnotation(OneToOne.class).mappedBy()))) {
            String columnName = field.isAnnotationPresent(JoinColumn.class)
                    ? field.getAnnotation(JoinColumn.class).name()
                    : field.getName();
            fi = getIdFieldInfo(type, name, columnName);
        } else if (!field.isAnnotationPresent(Transient.class)
                && (Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type))
                && (field.isAnnotationPresent(JoinColumn.class) || field.isAnnotationPresent(JoinTable.class)
                        || field.isAnnotationPresent(CollectionTable.class))) {
            fi = new FieldInfo(type, name);
        } else {
            continue;
        }
        if (field.isAnnotationPresent(Type.class)) {
            fi.addAnnotation(field.getAnnotation(Type.class));
        }
        fi.setField(field);
        fields.add(fi);
    }

    return fields;
}

From source file:org.xmlsh.util.JavaUtils.java

public static Class<?> fromPrimativeName(String name) {

    switch (name) {
    case "boolean":
        return java.lang.Boolean.TYPE;
    case "char":
        return java.lang.Character.TYPE;
    case "byte":
        return java.lang.Byte.TYPE;
    case "short":
        return java.lang.Short.TYPE;
    case "int":
        return java.lang.Integer.TYPE;
    case "long":
        return java.lang.Long.TYPE;
    case "float":
        return java.lang.Float.TYPE;
    case "double":
        return java.lang.Double.TYPE;
    case "void":
        return java.lang.Void.TYPE;
    default:/*from w w w. j a v a 2 s  . co  m*/
        return null;
    }

}

From source file:org.jsslutils.extra.apachetomcat5.JSSLutilsJSSESocketFactory.java

/**
 * Reads the keystore and initializes the SSL socket factory.
 *///from   www .  ja v  a 2 s.co  m
void init() throws IOException {
    try {
        String clientAuthStr = (String) attributes.get("clientauth");
        if ("true".equalsIgnoreCase(clientAuthStr) || "yes".equalsIgnoreCase(clientAuthStr)) {
            requireClientAuth = true;
        } else if ("want".equalsIgnoreCase(clientAuthStr)) {
            wantClientAuth = true;
        }

        // SSL protocol variant (e.g., TLS, SSL v3, etc.)
        String protocol = (String) attributes.get("protocol");
        if (protocol == null) {
            protocol = defaultProtocol;
        }

        String keyPassAttr = (String) attributes.get("keypass");

        KeyStoreLoader ksl = KeyStoreLoader.getKeyStoreDefaultLoader();
        String keystoreFileAttr = (String) attributes.get("keystoreFile");
        if (keystoreFileAttr == null)
            keystoreFileAttr = (String) attributes.get("keystore");
        if (keystoreFileAttr != null) {
            ksl.setKeyStorePath(keystoreFileAttr.length() == 0 ? null : keystoreFileAttr);
        }
        String keystorePassAttr = (String) attributes.get("keystorePass");
        if (keystorePassAttr == null)
            keystorePassAttr = keyPassAttr;
        if (keystorePassAttr != null)
            ksl.setKeyStorePassword(keystorePassAttr);
        String keystoreTypeAttr = (String) attributes.get("keystoreType");
        ksl.setKeyStoreType(keystoreTypeAttr != null ? keystoreTypeAttr : KeyStore.getDefaultType());
        String keystoreProviderAttr = (String) attributes.get("keystoreProvider");
        if (keystoreProviderAttr != null) {
            ksl.setKeyStoreProvider(keystoreProviderAttr.length() == 0 ? null : keystoreProviderAttr);
        }

        KeyStoreLoader tsl = KeyStoreLoader.getTrustStoreDefaultLoader();
        String truststoreFileAttr = (String) attributes.get("truststoreFile");
        if (truststoreFileAttr != null) {
            tsl.setKeyStorePath(truststoreFileAttr.length() == 0 ? null : truststoreFileAttr);
        }
        String truststorePassAttr = (String) attributes.get("truststorePass");
        if (truststorePassAttr != null)
            tsl.setKeyStorePassword(truststorePassAttr);
        String truststoreTypeAttr = (String) attributes.get("truststoreType");
        tsl.setKeyStoreType(truststoreTypeAttr != null ? truststoreTypeAttr : KeyStore.getDefaultType());
        String truststoreProviderAttr = (String) attributes.get("truststoreProvider");
        if (truststoreProviderAttr != null) {
            tsl.setKeyStoreProvider(truststoreProviderAttr.length() == 0 ? null : truststoreProviderAttr);
        }

        KeyStore keyStore = ksl.loadKeyStore();
        KeyStore trustStore = tsl.loadKeyStore();

        PKIXSSLContextFactory sslContextFactory = new PKIXSSLContextFactory(keyStore, keyPassAttr, trustStore);

        String crlURLsAttr = (String) attributes.get("crlURLs");
        if (crlURLsAttr != null) {
            StringTokenizer st = new StringTokenizer(crlURLsAttr, " ");
            while (st.hasMoreTokens()) {
                String crlUrl = st.nextToken();
                sslContextFactory.addCrl(crlUrl);
            }
        }

        String acceptAnyCert = (String) attributes.get("acceptAnyCert");
        if ("true".equalsIgnoreCase(acceptAnyCert) || "yes".equalsIgnoreCase(acceptAnyCert)) {
            sslContextFactory.setTrustManagerWrapper(new TrustAllClientsWrappingTrustManager.Wrapper());
        } else {
            String acceptProxyCertsAttr = (String) attributes.get("acceptProxyCerts");
            if ((acceptProxyCertsAttr != null) && (acceptProxyCertsAttr.length() > 0)) {
                boolean allowLegacy = false;
                boolean allowPreRfc = false;
                boolean allowRfc3820 = false;
                String[] acceptProxyTypes = acceptProxyCertsAttr.split(",");
                for (int i = 0; i < acceptProxyTypes.length; i++) {
                    if ("legacy".equalsIgnoreCase(acceptProxyTypes[i].trim())) {
                        allowLegacy = true;
                    }
                    if ("prerfc".equalsIgnoreCase(acceptProxyTypes[i].trim())) {
                        allowPreRfc = true;
                    }
                    if ("rfc3820".equalsIgnoreCase(acceptProxyTypes[i].trim())) {
                        allowRfc3820 = true;
                    }
                }

                if (allowLegacy || allowPreRfc || allowRfc3820) {
                    try {
                        Class<?> wrapperClass = Class
                                .forName("org.jsslutils.extra.gsi.GsiWrappingTrustManager");
                        Constructor<?> constructor = wrapperClass.getConstructor(Boolean.TYPE, Boolean.TYPE,
                                Boolean.TYPE);
                        X509TrustManagerWrapper wrapper = (X509TrustManagerWrapper) constructor
                                .newInstance(allowLegacy, allowPreRfc, allowRfc3820);
                        sslContextFactory.setTrustManagerWrapper(wrapper);
                    } catch (ClassNotFoundException e) {
                        throw new Exception(
                                "Unable to load org.jsslutils.extra.gsi.GsiWrappingTrustManager, please put the required files on the class path.",
                                e);
                    } catch (NoSuchMethodException e) {
                        throw new Exception(
                                "Unable to load org.jsslutils.extra.gsi.GsiWrappingTrustManager, please put the required files on the class path.",
                                e);
                    } catch (SecurityException e) {
                        throw new Exception(
                                "Unable to load org.jsslutils.extra.gsi.GsiWrappingTrustManager, please put the required files on the class path.",
                                e);
                    } catch (ClassCastException e) {
                        throw new Exception(
                                "Unable to load org.jsslutils.extra.gsi.GsiWrappingTrustManager, please put the required files on the class path.",
                                e);
                    }
                }
            }
        }

        // Create and init SSLContext
        SSLContext context = sslContextFactory.buildSSLContext(protocol);

        // create proxy
        sslProxy = context.getServerSocketFactory();

        // Determine which cipher suites to enable
        String requestedCiphers = (String) attributes.get("ciphers");
        enabledCiphers = getEnabledCiphers(requestedCiphers, sslProxy.getSupportedCipherSuites());

    } catch (Exception e) {
        if (e instanceof IOException)
            throw (IOException) e;
        throw new IOException(e.getMessage());
    }
}

From source file:com.gdcn.modules.db.jdbc.processor.CamelBeanProcessor.java

/**
 * ResultSet.getObject() returns an Integer object for an INT column.  The
 * setter method for the property might take an Integer or a primitive int.
 * This method returns true if the value can be successfully passed into
 * the setter method.  Remember, Method.invoke() handles the unwrapping
 * of Integer into an int./*from  w w w  .j  av  a 2  s  . com*/
 *
 * @param value The value to be passed into the setter method.
 * @param type The setter's parameter type (non-null)
 * @return boolean True if the value is compatible (null => true)
 */
private boolean isCompatibleType(Object value, Class<?> type) {
    // Do object check first, then primitives
    if (value == null || type.isInstance(value)) {
        return true;

    } else if (type.equals(Integer.TYPE) && Integer.class.isInstance(value)) {
        return true;

    } else if (type.equals(Long.TYPE) && Long.class.isInstance(value)) {
        return true;

    } else if (type.equals(Double.TYPE) && Double.class.isInstance(value)) {
        return true;

    } else if (type.equals(Float.TYPE) && Float.class.isInstance(value)) {
        return true;

    } else if (type.equals(Short.TYPE) && Short.class.isInstance(value)) {
        return true;

    } else if (type.equals(Byte.TYPE) && Byte.class.isInstance(value)) {
        return true;

    } else if (type.equals(Character.TYPE) && Character.class.isInstance(value)) {
        return true;

    } else if (type.equals(Boolean.TYPE) && Boolean.class.isInstance(value)) {
        return true;

    }
    return false;

}

From source file:com.nonninz.robomodel.RoboModel.java

void saveField(Field field, TypedContentValues cv) {
    final Class<?> type = field.getType();
    final boolean wasAccessible = field.isAccessible();
    field.setAccessible(true);// w ww.  j  a v a 2 s.c  o  m

    try {
        if (type == String.class) {
            cv.put(field.getName(), (String) field.get(this));
        } else if (type == Boolean.TYPE) {
            cv.put(field.getName(), field.getBoolean(this));
        } else if (type == Byte.TYPE) {
            cv.put(field.getName(), field.getByte(this));
        } else if (type == Double.TYPE) {
            cv.put(field.getName(), field.getDouble(this));
        } else if (type == Float.TYPE) {
            cv.put(field.getName(), field.getFloat(this));
        } else if (type == Integer.TYPE) {
            cv.put(field.getName(), field.getInt(this));
        } else if (type == Long.TYPE) {
            cv.put(field.getName(), field.getLong(this));
        } else if (type == Short.TYPE) {
            cv.put(field.getName(), field.getShort(this));
        } else if (type.isEnum()) {
            final Object value = field.get(this);
            if (value != null) {
                final Method method = type.getMethod("name");
                final String str = (String) method.invoke(value);
                cv.put(field.getName(), str);
            }
        } else {
            // Try to JSONify it (db column must be of type text)
            final String json = mMapper.writeValueAsString(field.get(this));
            cv.put(field.getName(), json);
        }
    } catch (final IllegalAccessException e) {
        final String msg = String.format("Field %s is not accessible", type, field.getName());
        throw new IllegalArgumentException(msg);
    } catch (final JsonProcessingException e) {
        Ln.w(e, "Error while dumping %s of type %s to Json", field.getName(), type);
        final String msg = String.format("Field %s is not accessible", type, field.getName());
        throw new IllegalArgumentException(msg);
    } catch (final NoSuchMethodException e) {
        // Should not happen
        throw new RuntimeException(e);
    } catch (final InvocationTargetException e) {
        // Should not happen
        throw new RuntimeException(e);
    } finally {
        field.setAccessible(wasAccessible);
    }
}