Example usage for com.google.common.base CaseFormat LOWER_CAMEL

List of usage examples for com.google.common.base CaseFormat LOWER_CAMEL

Introduction

In this page you can find the example usage for com.google.common.base CaseFormat LOWER_CAMEL.

Prototype

CaseFormat LOWER_CAMEL

To view the source code for com.google.common.base CaseFormat LOWER_CAMEL.

Click Source Link

Document

Java variable naming convention, e.g., "lowerCamel".

Usage

From source file:org.killbill.commons.jdbi.mapper.LowerToCamelBeanMapper.java

public LowerToCamelBeanMapper(final Class<T> type) {
    this.type = type;
    try {/* ww w .  j a  v a2s.  com*/
        final BeanInfo info = Introspector.getBeanInfo(type);

        for (final PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
            properties.put(
                    CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, descriptor.getName()).toLowerCase(),
                    descriptor);
        }
    } catch (final IntrospectionException e) {
        throw new IllegalArgumentException(e);
    }
}

From source file:com.facebook.buck.query.AttrFilterFunction.java

@Override
public Set<QueryTarget> eval(QueryEnvironment env, ImmutableList<Argument> args,
        ListeningExecutorService executor) throws QueryException, InterruptedException {
    QueryExpression argument = args.get(args.size() - 1).getExpression();
    String attr = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, args.get(0).getWord());

    final String attrValue = args.get(1).getWord();
    final Predicate<Object> predicate = input -> attrValue.equals(input.toString());

    Set<QueryTarget> result = new LinkedHashSet<>();
    for (QueryTarget target : argument.eval(env, executor)) {
        ImmutableSet<Object> matchingObjects = env.filterAttributeContents(target, attr, predicate);
        if (!matchingObjects.isEmpty()) {
            result.add(target);//  w  w  w  . j  av  a  2  s  .c  o  m
        }
    }
    return result;
}

From source file:org.lendingclub.mercator.docker.DockerSerializerModule.java

public ObjectNode flatten(JsonNode n) {
    ObjectNode out = vanillaObjectMapper.createObjectNode();
    Converter<String, String> caseFormat = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_CAMEL);

    n.fields().forEachRemaining(it -> {
        JsonNode val = it.getValue();
        String key = it.getKey();
        key = caseFormat.convert(key);/* w  w w .  ja  va  2s . com*/
        if (val.isValueNode()) {

            out.set(key, it.getValue());
        } else if (val.isArray()) {
            if (val.size() == 0) {
                out.set(key, val);
            }
            boolean valid = true;
            Class<? extends Object> type = null;
            ArrayNode an = (ArrayNode) val;
            for (int i = 0; valid && i < an.size(); i++) {
                if (!an.get(i).isValueNode()) {
                    valid = false;
                }
                if (type != null && an.get(i).getClass() != type) {
                    valid = false;
                }
            }

        }
    });
    renameAttribute(out, "oSType", "osType");
    renameAttribute(out, "iD", "id");
    renameAttribute(out, "neventsListener", "nEventsListener");
    renameAttribute(out, "cPUSet", "cpuSet");
    renameAttribute(out, "cPUShares", "cpuShares");
    renameAttribute(out, "iPv4Forwarding", "ipv4Forwarding");
    renameAttribute(out, "oOMKilled", "oomKilled");
    renameAttribute(out, "state_oomkilled", "state_oomKilled");
    renameAttribute(out, "bridgeNfIptables", "bridgeNfIpTables");
    renameAttribute(out, "bridgeNfIp6tables", "bridgeNfIp6Tables");
    out.remove("ngoroutines");
    return out;
}

From source file:org.dbunitng.beans.BeanMetaData.java

/**
 * ????//w ww.  j a  v a2  s.  co m
 */
protected void retrievePropertiesByField() {
    Field[] fields = targetClass.getFields();

    for (int i = 0; i < fields.length; ++i) {

        Field field = fields[i];
        field.setAccessible(true);

        if (PropertyUtil.isInstanceField(field)) {
            String fname = field.getName();
            BeanProperty property = propertyMap.get(fname);
            if (property == null) {
                property = new BeanProperty(fname, field.getType(), field, null, null);
                propertyMap.put(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fname), property);
            } else if (PropertyUtil.isPublicField(field)) {
                property.setField(field);
            }
        }
    }
}

From source file:aritzh.waywia.universe.World.java

public static World newWorld(String name, File universeFolder) throws IOException {
    String folderName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, name);
    File root = new File(universeFolder, folderName);

    if (!root.exists() && !root.mkdirs())
        throw new IOException("Could not create folder for new world at: " + root.getAbsolutePath());

    BDSCompound customData = new BDSCompound("CustomData");
    Multimap<String, Entity> entities = ArrayListMultimap.create();
    HashMap<String, Player> player = Maps.newHashMap();
    Matrix<Block> blocks = new Matrix<>(50, 38, new BackgroundBlock());

    return new World(name, root, customData, entities, player, blocks);
}

From source file:com.googlesource.gerrit.plugins.kafka.config.KafkaProperties.java

private void applyConfig(PluginConfig config) {
    for (String name : config.getNames()) {
        Object value = config.getString(name);
        String propName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name).replaceAll("-", ".");
        put(propName, value);//from   w  w  w  . j a  va 2s . c  om
    }
}

From source file:com.google.javascript.jscomp.GoogleJsMessageIdGenerator.java

@Override
public String generateId(String meaning, List<CharSequence> messageParts) {
    Preconditions.checkState(meaning != null);

    StringBuilder sb = new StringBuilder();
    for (CharSequence part : messageParts) {
        if (part instanceof PlaceholderReference) {
            sb.append(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE,
                    ((PlaceholderReference) part).getName()));
        } else {// w ww. j ava 2s . c  o m
            sb.append(part);
        }
    }
    String tcValue = sb.toString();

    String projectScopedMeaning = (projectId != null ? (projectId + ": ") : "") + meaning;
    return String.valueOf(MessageId.generateId(tcValue, projectScopedMeaning));
}

From source file:org.apache.airavata.db.AbstractThriftSerializer.java

@Override
public void serialize(final T value, final JsonGenerator jgen, final SerializerProvider provider)
        throws IOException {
    jgen.writeStartObject();//  www .  j a  va  2  s  .c  om
    for (final E field : getFieldValues()) {
        if (value.isSet(field)) {
            final Object fieldValue = value.getFieldValue(field);
            if (fieldValue != null) {
                log.debug("Adding field {} to the JSON string...",
                        CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));

                jgen.writeFieldName(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
                if (fieldValue instanceof Short) {
                    jgen.writeNumber((Short) fieldValue);
                } else if (fieldValue instanceof Integer) {
                    jgen.writeNumber((Integer) fieldValue);
                } else if (fieldValue instanceof Long) {
                    jgen.writeNumber((Long) fieldValue);
                } else if (fieldValue instanceof Double) {
                    jgen.writeNumber((Double) fieldValue);
                } else if (fieldValue instanceof Float) {
                    jgen.writeNumber((Float) fieldValue);
                } else if (fieldValue instanceof Boolean) {
                    jgen.writeBoolean((Boolean) fieldValue);
                } else if (fieldValue instanceof String) {
                    jgen.writeString(fieldValue.toString());
                } else if (fieldValue instanceof Collection) {
                    log.debug("Array opened for field {}.",
                            CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
                    jgen.writeStartArray();
                    for (final Object arrayObject : (Collection<?>) fieldValue) {
                        jgen.writeObject(arrayObject);
                    }
                    jgen.writeEndArray();
                    log.debug("Array closed for field {}.",
                            CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
                } else {
                    jgen.writeObject(fieldValue);
                }
            } else {
                log.debug("Skipping converting field {} to JSON:  value is null!",
                        CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
            }
        } else {
            log.debug("Skipping converting field {} to JSON:  field has not been set!",
                    CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
        }
    }
    jgen.writeEndObject();
}

From source file:org.smartdeveloperhub.harvesters.it.frontend.util.AbstractCappedContainerHandler.java

@Override
public final ResourceSnapshot create(final ContainerSnapshot container, final DataSet representation,
        final WriteSession session) {
    trace("Requested %s creation from: %n%s", this.artifact, representation);
    throw super.unexpectedFailure("%s creation is not supported",
            CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, this.artifact));
}

From source file:com.facebook.buck.jvm.java.AnnotationProcessingEvent.java

public String getCategory() {
    return annotationProcessorName + "."
            + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, operation.toString());
}