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

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

Introduction

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

Prototype

CaseFormat UPPER_UNDERSCORE

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

Click Source Link

Document

Java and C++ constant naming convention, e.g., "UPPER_UNDERSCORE".

Usage

From source file:org.geoserver.security.iride.service.policy.IridePolicy.java

/**
 * Returns the <code>IRIDE</code> "policy" <code>service name</code>, i.e.: the name of the operation.
 *
 * @return the <code>IRIDE</code> "policy" <code>service name</code>, i.e.: the name of the operation
 *//* w  w w.j a v a  2 s .  com*/
public String getServiceName() {
    return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, this.name());
}

From source file:com.google.api.codegen.util.Name.java

/**
 * Creates a Name from a sequence of upper-underscore strings.
 *
 * @throws IllegalArgumentException if any of the strings contain any characters that are not
 *     upper case or underscores.//from  www. j  a  v  a2s  .  c om
 */
public static Name upperUnderscore(String... pieces) {
    List<NamePiece> namePieces = new ArrayList<>();
    for (String piece : pieces) {
        if (Strings.isNullOrEmpty(piece)) {
            continue;
        }
        validateUpperUnderscore(piece);
        namePieces.add(new NamePiece(piece, CaseFormat.UPPER_UNDERSCORE));
    }
    return new Name(namePieces);
}

From source file:org.jclouds.s3.domain.Payer.java

public static Payer fromValue(String payer) {
    try {/*  w  w w .  j av a 2s . co  m*/
        return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, payer));
    } catch (IllegalArgumentException e) {
        return UNRECOGNIZED;
    }
}

From source file:com.github.ko2ic.plugin.eclipse.taggen.common.domain.valueobject.NameRuleString.java

public String toUpperCamel() {
    String value = str;/*from  w ww  .j  a  v  a2  s.  com*/
    if (Character.isUpperCase(str.charAt(0))) {
        if (str.contains("_")) {
            value = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, str);
        }
    } else {
        if (str.contains("_")) {
            value = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, str);
        } else {
            value = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, str);
        }
    }
    return value;
}

From source file:growthcraft.api.core.item.EnumDye.java

public String getOreName() {
    return String.format("dye%s", CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()));
}

From source file:org.openehr.designer.json.AmTypeIdResolver.java

private void addClassesFromObjectFactory(Map<String, Class> target, Class<?> objectFactory) {
    for (Method method : objectFactory.getMethods()) {
        if (method.getName().startsWith("create")) {
            if (method.getParameterCount() == 0) {
                Class c = method.getReturnType();
                target.put(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, c.getSimpleName()), c);
            } else {
                Class c = method.getParameterTypes()[0];
                target.put(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, c.getSimpleName()), c);
            }//  www .  j av  a 2 s  . c  o  m
        }
    }
}

From source file:com.opengamma.strata.product.credit.type.CdsQuoteConvention.java

/**
 * Obtains an instance from the specified unique name.
 * //from  w  w  w  .j  ava 2 s . c o  m
 * @param uniqueName  the unique name
 * @return the type
 * @throws IllegalArgumentException if the name is not known
 */
@FromString
public static CdsQuoteConvention of(String uniqueName) {
    ArgChecker.notNull(uniqueName, "uniqueName");
    return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, uniqueName));
}

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 {//from  ww  w.  ja v  a2 s. 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:com.github.herong.rpc.netty.protobuf.demo3.Demo3ProtobufServerHandler.java

private void invokeHandle(Commands.Command decoded) throws Exception {
    Command.CommandType com = decoded.getType();
    String methodName = "handle" + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, com.name());

    for (Method method : getClass().getDeclaredMethods()) {
        if (method.getName().equalsIgnoreCase(methodName)) {
            method.setAccessible(true);//from  w  w  w. ja  v a  2s. com
            Class[] types = method.getParameterTypes();
            Class cmdType = types[0];
            Field f = cmdType.getField("cmd");
            GeneratedMessage.GeneratedExtension ext = (GeneratedMessage.GeneratedExtension) f.get(decoded);

            method.invoke(this, decoded.getExtension(ext));
            break;
        }
    }
}

From source file:com.opengamma.strata.collect.named.EnumNames.java

private EnumNames(Class<T> enumType, boolean manualToString) {
    ArgChecker.notNull(enumType, "enumType");
    SortedMap<String, T> map = new TreeMap<>();
    SortedSet<String> formattedSet = new TreeSet<>();
    EnumMap<T, String> formatMap = new EnumMap<>(enumType);
    for (T value : enumType.getEnumConstants()) {
        String formatted = manualToString ? value.toString()
                : CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, value.name());
        map.put(value.name(), value);//  w ww.jav  a 2s .co m
        map.put(value.name().toUpperCase(Locale.ENGLISH), value);
        map.put(value.name().toLowerCase(Locale.ENGLISH), value);
        map.put(formatted, value);
        map.put(formatted.toUpperCase(Locale.ENGLISH), value);
        map.put(formatted.toLowerCase(Locale.ENGLISH), value);
        formattedSet.add(formatted);
        formatMap.put(value, formatted);
    }
    this.parseMap = ImmutableSortedMap.copyOf(map);
    this.formattedSet = ImmutableSortedSet.copyOf(formattedSet);
    this.formatMap = formatMap;
}