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.ow2.proactive.scheduling.api.graphql.fetchers.TaskDataFetcher.java

@Override
protected Stream<Task> dataMapping(Stream<TaskData> dataStream) {
    // TODO Task progress not accessible from DB. It implies to establish a connection with
    // the SchedulerFrontend active object to get the value that is in the Scheduler memory

    return dataStream.map(taskData -> {
        TaskData.DBTaskId id = taskData.getId();

        return Task.builder().additionalClasspath(taskData.getAdditionalClasspath())
                .description(taskData.getDescription()).executionDuration(taskData.getExecutionDuration())
                .executionHostname(taskData.getExecutionHostName()).finishedTime(taskData.getFinishedTime())
                .genericInformation(taskData.getGenericInformation()).id(id.getTaskId())
                .inErrorTime(taskData.getInErrorTime()).javaHome(taskData.getJavaHome()).jobId(id.getJobId())
                .jvmArguments(taskData.getJvmArguments())
                .maxNumberOfExecution(taskData.getMaxNumberOfExecution()).name(taskData.getTaskName())
                .numberOfExecutionLeft(taskData.getNumberOfExecutionLeft())
                .numberOfExecutionOnFailureLeft(taskData.getNumberOfExecutionOnFailureLeft())
                .onTaskError(//from ww w  .  j  a v a  2s  .  co  m
                        CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, taskData.getOnTaskErrorString()))
                .preciousLogs(taskData.isPreciousLogs()).preciousResult(taskData.isPreciousResult())
                .restartMode(RestartMode.getMode(taskData.getRestartModeId()).getDescription().toUpperCase())
                .resultPreview(taskData.getResultPreview()).runAsMe(taskData.isRunAsMe())
                .scheduledTime(taskData.getScheduledTime()).startTime(taskData.getStartTime())
                .status(taskData.getTaskStatus().name()).tag(taskData.getTag())
                .variables(taskData.getVariables().values().stream()
                        .map(taskDataVariable -> Maps.immutableEntry(taskDataVariable.getName(),
                                taskDataVariable.getValue()))
                        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)))
                .workingDir(taskData.getWorkingDir()).walltime(taskData.getWallTime()).build();
    });
}

From source file:com.cinchapi.concourse.server.plugin.PluginConfiguration.java

/**
 * Define a default preference to be used if not provided in the prefs file.
 * //from  w  w  w.j  a v a 2 s  . c o m
 * @param key
 * @param value
 */
protected void addDefault(String key, Object value) {
    SystemPreference sys = null;
    try {
        sys = SystemPreference.valueOf(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_UNDERSCORE, key));
    } catch (IllegalArgumentException e) {
        /* no-op */}
    if (sys != null) {
        addDefault(sys, value);
    } else {
        defaults.put(key, value);
    }
}

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

private static Name camelInternal(CheckCase checkCase, AcronymMode acronymMode, String... pieces) {
    List<NamePiece> namePieces = new ArrayList<>();
    for (String piece : pieces) {
        if (Strings.isNullOrEmpty(piece)) {
            continue;
        }// w  w  w .  java2  s.c  om
        validateCamel(piece, checkCase);
        for (SubNamePiece subPiece : CommonAcronyms.splitByUpperAcronyms(piece)) {
            CaseFormat caseFormat = getCamelCaseFormat(subPiece.namePieceString());
            CasingMode casingMode = CasingMode.NORMAL;
            if (subPiece.type().equals(NamePieceCasingType.UPPER_ACRONYM)) {
                caseFormat = CaseFormat.UPPER_UNDERSCORE;
                casingMode = acronymMode.casingMode;
            }
            namePieces.add(new NamePiece(subPiece.namePieceString(), caseFormat, casingMode));
        }
    }
    return new Name(namePieces);
}

From source file:net.hydromatic.tpcds.TpcdsTable.java

private static <E extends TpcdsEntity> TpcdsTable<E> dummy(String name, final String prefix, Class<E> clazz) {
    ImmutableList.Builder<TpcdsColumn> columns = ImmutableList.builder();
    for (final Field field : clazz.getFields()) {
        columns.add(new TpcdsColumn() {
            public String getString(Object o) {
                throw new UnsupportedOperationException();
            }//  www .j av  a2s  . c  o m

            public double getDouble(Object o) {
                throw new UnsupportedOperationException();
            }

            public long getLong(Object o) {
                throw new UnsupportedOperationException();
            }

            public String getColumnName() {
                return prefix + "_" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, field.getName());
            }

            public Class<?> getType() {
                return field.getType();
            }
        });
    }
    return new TpcdsTable<E>(name, prefix, columns.build()) {
        @Override
        public Iterable<E> createGenerator(double scaleFactor, int part, int partCount) {
            return ImmutableList.of();
        }

        @Override
        public void builder(Dsgen dsgen) {
        }

        @Override
        public void loader1() {
        }

        @Override
        public void loader2() {
        }

        @Override
        public void validate(int nTable, long kRow, int[] permutation) {
        }
    };
}

From source file:fr.zcraft.zlib.components.rawtext.RawText.java

static public JSONObject toJSON(Entity entity) {
    JSONObject obj = new JSONObject();

    String name = entity.getCustomName();
    if (name == null || name.isEmpty())
        name = entity.getName();/*from   ww  w  .jav  a2 s.co m*/

    obj.put("name", name);
    obj.put("type", CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entity.getType().toString()));
    obj.put("id", entity.getUniqueId().toString());

    return obj;
}

From source file:com.android.tools.idea.ui.properties.demo.CorePropertiesDemo.java

public CorePropertiesDemo() {
    final Person person = new Person();

    for (Gender gender : Gender.values()) {
        myGenderCombo.addItem(gender);/*  w w w.  ja  v  a 2s.  c o m*/
    }
    myGenderCombo.setSelectedItem(person.myGender.get());

    /**
     * Hook up the first panel (which modifies the target person)
     */
    myBindings.bindTwoWay(new TextProperty(myNameTextField), person.myName);
    myBindings.bindTwoWay(new SliderValueProperty(myAgeSlider), person.myAge);
    myBindings.bind(new TextProperty(myAgeLabel), new FormatExpression("%d", person.myAge));
    myBindings.bindTwoWay(new SelectedProperty(myCitizenshipCheckBox), person.myIsCitizen);
    final TextProperty employerName = new TextProperty(myEmployerTextField);
    myBindings.bind(person.myEmployer, new Expression<Optional<String>>(employerName) {
        @NotNull
        @Override
        public Optional<String> get() {
            return employerName.get().trim().isEmpty() ? Optional.empty() : Optional.of(employerName.get());
        }
    });
    SelectedItemProperty<Gender> selectedGender = new SelectedItemProperty<>(myGenderCombo);
    myBindings.bind(person.myGender,
            new TransformOptionalExpression<Gender, Gender>(Gender.OTHER, selectedGender) {
                @NotNull
                @Override
                protected Gender transform(@NotNull Gender gender) {
                    return gender;
                }
            });

    /**
     * Hook up the second panel (which prints out useful information about the person)
     */
    myBindings.bind(new TextProperty(myIsValidNameLabel), new YesNoExpression(person.myName.isEmpty().not()));
    myBindings.bind(new TextProperty(myGenderLabel), new StringExpression(person.myGender) {
        @NotNull
        @Override
        public String get() {
            return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, person.myGender.toString());
        }
    });
    myBindings.bind(new TextProperty(myCanVoteLabel),
            new YesNoExpression(person.myIsCitizen.and(person.myAge.isGreaterThanEqualTo(16))));
    myBindings.bind(new TextProperty(myHasEmployerLabel),
            new TransformOptionalExpression<String, String>("No", person.myEmployer) {
                @NotNull
                @Override
                protected String transform(@NotNull String value) {
                    return String.format("Yes (%s)", value.trim());
                }
            });
}

From source file:com.github.benmanes.caffeine.cache.Specifications.java

/** Returns the offset constant to this variable. */
public static String offsetName(String varName) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, varName) + "_OFFSET";
}

From source file:com.jedi.metadata.DatabaseMetadataUtil.java

public static List<ArgumentMetadata> getProcedureArguments(Connection connection,
        ProcedureMetadata procedureMetadata) throws SQLException {
    List<ArgumentMetadata> result = new ArrayList<ArgumentMetadata>();
    String sql = "SELECT ARGUMENT_NAME," + "       POSITION," + "       SEQUENCE," + "       DATA_TYPE,"
            + "       IN_OUT," + "       DATA_LENGTH," + "       DATA_PRECISION," + "       DATA_SCALE,"
            + "       RADIX," + "       TYPE_OWNER," + "       TYPE_NAME," + "       PLS_TYPE"
            + "  FROM ALL_ARGUMENTS" + " WHERE OBJECT_ID = " + procedureMetadata.getPackageId()
            + " AND SUBPROGRAM_ID = " + procedureMetadata.getId() + " AND DATA_LEVEL=0";
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(sql);
    while (resultSet.next()) {
        ArgumentMetadata argumentMetadata = new ArgumentMetadata();
        String argumentName = resultSet.getString("ARGUMENT_NAME");
        argumentMetadata.setName(argumentName);
        argumentMetadata.setPosition(resultSet.getInt("POSITION"));
        argumentMetadata.setSequence(resultSet.getInt("SEQUENCE"));
        String datatype = resultSet.getString("DATA_TYPE");
        argumentMetadata.setDataType(datatype);
        argumentMetadata.setInOut(resultSet.getString("IN_OUT"));
        argumentMetadata.setLength(resultSet.getInt("DATA_LENGTH"));
        argumentMetadata.setPrecision(resultSet.getInt("DATA_PRECISION"));
        argumentMetadata.setScale(resultSet.getInt("DATA_SCALE"));
        argumentMetadata.setRadix(resultSet.getInt("RADIX"));
        argumentMetadata.setCustomTypeOwner(resultSet.getString("TYPE_OWNER"));
        argumentMetadata.setCustomTypeName(resultSet.getString("TYPE_NAME"));
        argumentMetadata.setPlsType(resultSet.getString("PLS_TYPE"));

        if (argumentName != null && !argumentName.isEmpty()) {
            argumentName = argumentName.toUpperCase();
            if (argumentName.startsWith("P_")) {
                argumentName = argumentName.substring(2);
            }/*from  w w  w.j a  va2s .  c  o m*/
            String fieldName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, argumentName);
            argumentMetadata.setFieldName(fieldName);
        } else {
            String fieldName = "result";
            argumentMetadata.setFieldName(fieldName);
        }

        String javaType = getJavaType(datatype);
        argumentMetadata.setFieldType(javaType);

        result.add(argumentMetadata);
    }
    return result;

}

From source file:com.google.gcloud.Identity.java

/**
 * Converts a string to an {@code Identity}. Used primarily for converting protobuf-generated
 * policy identities to {@code Identity} objects.
 *///  w  w w  .java2 s .co  m
public static Identity valueOf(String identityStr) {
    String[] info = identityStr.split(":");
    Type type = Type.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, info[0]));
    switch (type) {
    case ALL_USERS:
        return Identity.allUsers();
    case ALL_AUTHENTICATED_USERS:
        return Identity.allAuthenticatedUsers();
    case USER:
        return Identity.user(info[1]);
    case SERVICE_ACCOUNT:
        return Identity.serviceAccount(info[1]);
    case GROUP:
        return Identity.group(info[1]);
    case DOMAIN:
        return Identity.domain(info[1]);
    default:
        throw new IllegalStateException("Unexpected identity type " + type);
    }
}

From source file:com.google.template.soy.parsepasses.contextautoesc.EscapingMode.java

EscapingMode(boolean escapesQuotes, @Nullable ContentKind contentKind, boolean internalOnly) {
    this.directiveName = "|" + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
    this.isHtmlEmbeddable = escapesQuotes;
    this.contentKind = contentKind;
    this.isInternalOnly = internalOnly;
}