@Override public String detect(String identifier) { if (identifier.length() <= lengthsOfPrefixAndSuffix) { return NOT_DETECTED; } boolean prefixMatches = prefix.isEmpty() || (identifier.startsWith(prefix) && Ascii.isUpperCase(identifier.charAt(prefix.length()))); boolean suffixMatches = suffix.isEmpty() || identifier.endsWith(suffix); if (prefixMatches && suffixMatches) { String detected = identifier.substring(prefix.length(), identifier.length() - suffix.length()); return prefix.isEmpty() ? detected : CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, detected); } return NOT_DETECTED; }
@Nullable private BoundAccessor resolveAccessorWithBeanAccessor(TypeMirror targetType, String attribute) { @Nullable BoundAccessor accessor = resolveAccessor(targetType, attribute); if (accessor != null) { return accessor; } String capitalizedName = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, attribute); accessor = resolveAccessor(targetType, "get" + capitalizedName); if (accessor != null) { return accessor; } accessor = resolveAccessor(targetType, "is" + capitalizedName); if (accessor != null) { return accessor; } accessor = resolveAccessor(targetType, "$$" + attribute); if (accessor != null) { return accessor; } return accessor; }
public static void genController(String tableName, String modelName) { try { freemarker.template.Configuration cfg = getConfiguration(); Map<String, Object> data = new HashMap<>(); data.put("date", DATE); data.put("author", AUTHOR); String modelNameUpperCamel = StringUtils.isEmpty(modelName) ? tableNameConvertUpperCamel(tableName) : modelName; data.put("baseRequestMapping", modelNameConvertMappingPath(modelNameUpperCamel)); data.put("modelNameUpperCamel", modelNameUpperCamel); data.put("modelNameLowerCamel", CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, modelNameUpperCamel)); data.put("basePackage", BASE_PACKAGE); File file = new File(PROJECT_PATH + JAVA_PATH + PACKAGE_PATH_CONTROLLER + modelNameUpperCamel + "Controller.java"); if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } //cfg.getTemplate("controller-restful.ftl").process(data, new FileWriter(file)); cfg.getTemplate("controller.ftl").process(data, new FileWriter(file)); System.out.println(modelNameUpperCamel + "Controller.java 生成成功"); } catch (Exception e) { throw new RuntimeException("生成Controller失败", e); } }
@Optional.Method(modid = ModIds.IGWMOD) private void onIGWAction() { int x = lastMouseX; int y = lastMouseY; IProgWidget hoveredWidget = programmerUnit.getHoveredWidget(x, y); if(hoveredWidget != null) { WikiRegistry.getWikiHooks().showWikiGui("pneumaticcraft:progwidget/" + CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, hoveredWidget.getWidgetString())); } for(IProgWidget widget : visibleSpawnWidgets) { if(widget != draggingWidget && x - guiLeft >= widget.getX() && y - guiTop >= widget.getY() && x - guiLeft <= widget.getX() + widget.getWidth() / 2 && y - guiTop <= widget.getY() + widget.getHeight() / 2) { WikiRegistry.getWikiHooks().showWikiGui("pneumaticcraft:progwidget/" + CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, widget.getWidgetString())); } } }
private String doCaseFormatting(String key, CaseFormat targetFormat) { if (targetFormat == null) { return key; } else { CaseFormat originalFormat = CaseFormat.LOWER_CAMEL; if (Character.isUpperCase(key.charAt(0)) && key.contains("_")) { originalFormat = CaseFormat.UPPER_UNDERSCORE; } else if (Character.isUpperCase(key.charAt(0))) { originalFormat = CaseFormat.UPPER_CAMEL; } else if (key.contains("_")) { originalFormat = CaseFormat.LOWER_UNDERSCORE; } else if (key.contains("-")) { originalFormat = CaseFormat.LOWER_HYPHEN; } return originalFormat.to(targetFormat, key); } }
/** * Test method for {@link com.github.ansell.rdf4j.schemagenerator.RDF4JSchemaGeneratorCore#generate(java.nio.file.Path)}. */ @Test public final void testUpperUnderscoreCase() throws Exception { Path outputPath = testDir.resolve("output"); Files.createDirectories(outputPath); RDF4JSchemaGeneratorCore testBuilder = new RDF4JSchemaGeneratorCore(inputPath.toAbsolutePath().toString(), format); testBuilder.setConstantCase(CaseFormat.UPPER_UNDERSCORE); Path javaFilePath = outputPath.resolve("Test.java"); testBuilder.generate(javaFilePath); assertTrue("Java file was not found", Files.exists(javaFilePath)); assertTrue("Java file was empty", Files.size(javaFilePath) > 0); ByteArrayOutputStream out = new ByteArrayOutputStream(); Files.copy(javaFilePath, out); String result = new String(out.toByteArray(), StandardCharsets.UTF_8); assertTrue("Did not find expected key case", result.contains("PROPERTY_LOCALISED4 = ")); assertTrue("Did not find original URI", result.contains("\"http://example.com/ns/ontology#propertyLocalised4\"")); }
/** * Test method for {@link com.github.ansell.rdf4j.schemagenerator.RDF4JSchemaGeneratorCore#generate(java.nio.file.Path)}. */ @Test public final void testUpperUnderscoreCaseString() throws Exception { Path outputPath = testDir.resolve("output"); Files.createDirectories(outputPath); RDF4JSchemaGeneratorCore testBuilder = new RDF4JSchemaGeneratorCore(inputPath.toAbsolutePath().toString(), format); testBuilder.setStringConstantCase(CaseFormat.UPPER_UNDERSCORE); Path javaFilePath = outputPath.resolve("Test.java"); testBuilder.generate(javaFilePath); assertTrue("Java file was not found", Files.exists(javaFilePath)); assertTrue("Java file was empty", Files.size(javaFilePath) > 0); ByteArrayOutputStream out = new ByteArrayOutputStream(); Files.copy(javaFilePath, out); String result = new String(out.toByteArray(), StandardCharsets.UTF_8); assertTrue("Did not find expected key case", result.contains("PROPERTY_LOCALISED4 = ")); assertTrue("Did not find original URI", result.contains("\"http://example.com/ns/ontology#propertyLocalised4\"")); }
/** * Test method for {@link com.github.ansell.rdf4j.schemagenerator.RDF4JSchemaGeneratorCore#generate(java.nio.file.Path)}. */ @Test public final void testUpperUnderscoreCaseLocalName() throws Exception { Path outputPath = testDir.resolve("output"); Files.createDirectories(outputPath); RDF4JSchemaGeneratorCore testBuilder = new RDF4JSchemaGeneratorCore(inputPath.toAbsolutePath().toString(), format); testBuilder.setLocalNameStringConstantCase(CaseFormat.UPPER_UNDERSCORE); Path javaFilePath = outputPath.resolve("Test.java"); testBuilder.generate(javaFilePath); assertTrue("Java file was not found", Files.exists(javaFilePath)); assertTrue("Java file was empty", Files.size(javaFilePath) > 0); ByteArrayOutputStream out = new ByteArrayOutputStream(); Files.copy(javaFilePath, out); String result = new String(out.toByteArray(), StandardCharsets.UTF_8); assertTrue("Did not find expected key case", result.contains("PROPERTY_LOCALISED4 = ")); assertTrue("Did not find original URI", result.contains("\"http://example.com/ns/ontology#propertyLocalised4\"")); }
/** * @param berichtStamgegevens stamgegevens * @param writer de writer */ public static void write(final BerichtStamgegevens berichtStamgegevens, BerichtWriter writer) { if (berichtStamgegevens.getStamtabelGegevens() == null) { return; } final String lowerCamelCaseNaam = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, berichtStamgegevens .getStamtabelGegevens().getStamgegevenTabel().getNaam()); writer.startElement(lowerCamelCaseNaam + StamtabelGegevens.TABEL_POSTFIX); for (Map<String, Object> stringObjectMap : berichtStamgegevens.getStamtabelGegevens().getStamgegevens()) { //xml stamgegeven tabel writer.startElement(lowerCamelCaseNaam); writer.attribute("objecttype", berichtStamgegevens.getStamtabelGegevens().getStamgegevenTabel().getNaam()); //elementen for (AttribuutElement attribuutElement : berichtStamgegevens.getStamtabelGegevens().getStamgegevenTabel() .getStamgegevenAttributenInBericht()) { schrijfStamgegevenWaarde(writer, stringObjectMap, attribuutElement); } writer.endElement(); } writer.endElement(); }
public Map<String, Rule> parseCustomRules(String fileName) throws IOException { Map<String, Rule> rules = gatherRules(); if (null != fileName) { File file = new File(fileName); ObjectMapper objectMapper = new ObjectMapper(); TypeReference<HashMap<String, Boolean>> typeReference = new TypeReference<HashMap<String, Boolean>>() { }; Map<String, Boolean> customRules = objectMapper.readValue(file, typeReference); for (Map.Entry<String, Boolean> entry : customRules.entrySet()) { if (rules.containsKey(entry.getKey().toLowerCase())) { Rule rule = rules.get(entry.getKey()); rule.setBreakingChange(entry.getValue()); rules.put(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, rule.getRuleName()), rule); LOGGER.info("Submited Rule " + rule.getRuleName() + " to " + entry.getValue()); } } } return rules; }
private ImmutableMap<TypeMirror, FieldSpec> getTypeAdapters(ImmutableList<Property> properties) { Map<TypeMirror, FieldSpec> typeAdapters = new LinkedHashMap<>(); NameAllocator nameAllocator = new NameAllocator(); nameAllocator.newName("CREATOR"); for (Property property : properties) { if (property.typeAdapter != null && !typeAdapters.containsKey(property.typeAdapter)) { ClassName typeName = (ClassName) TypeName.get(property.typeAdapter); String name = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, typeName.simpleName()); name = nameAllocator.newName(name, typeName); typeAdapters.put(property.typeAdapter, FieldSpec.builder( typeName, NameAllocator.toJavaIdentifier(name), PRIVATE, STATIC, FINAL) .initializer("new $T()", typeName).build()); } } return ImmutableMap.copyOf(typeAdapters); }
Clazz(Database database, org.antology.db.Node clazzNode) throws IOException { this.database = database; this.name = clazzNode.getProperty("name").getString(); this.schema = new Schema(clazzNode.getProperty("schema")); this.actions = new HashMap<>(); org.antology.db.Node actionsNode = clazzNode.getProperty("actions"); for (org.antology.db.Node actionNode : actionsNode.getElements()) { actions.put(actionNode.getProperty("name").getString(), new Action(this, actionNode)); } // Load objects String file = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name) + ".objects.json"; this.objects = new org.antology.db.json.Node( new File(((org.antology.db.json.Database) database).getPath() + "/" + file)); }
private ImmutableMap<TypeMirror, FieldSpec> getTypeAdapters(List<JsonProperty> properties, NameAllocator nameAllocator) { Map<TypeMirror, FieldSpec> typeAdapters = new LinkedHashMap<>(); for (JsonProperty property : properties) { if (property.typeAdapter != null && !typeAdapters.containsKey(property.typeAdapter)) { ClassName typeName = (ClassName) TypeName.get(property.typeAdapter); String name = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, typeName.simpleName()); name = nameAllocator.newName(name, typeName); typeAdapters.put(property.typeAdapter, FieldSpec.builder(typeName, NameAllocator.toJavaIdentifier(name), PRIVATE, STATIC, FINAL).initializer("new $T()", typeName).build()); } } return ImmutableMap.copyOf(typeAdapters); }
private String buildWhere(final String tableName, final Collection<String> tableFields, final Condition condition) { StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.append(" WHERE 1=1"); if (null != condition.getFields() && !condition.getFields().isEmpty()) { for (Map.Entry<String, Object> entry : condition.getFields().entrySet()) { String lowerUnderscore = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entry.getKey()); if (null != entry.getValue() && tableFields.contains(lowerUnderscore)) { sqlBuilder.append(" AND ").append(lowerUnderscore).append("=?"); } } } if (null != condition.getStartTime()) { sqlBuilder.append(" AND ").append(getTableTimeField(tableName)).append(">=?"); } if (null != condition.getEndTime()) { sqlBuilder.append(" AND ").append(getTableTimeField(tableName)).append("<=?"); } return sqlBuilder.toString(); }
public String apply(String input) { if (!input.isEmpty()) { if (this == CAPITALIZED && !Ascii.isUpperCase(input.charAt(0))) { return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, input); } if (this == LOWERIZED && !Ascii.isLowerCase(input.charAt(0))) { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, input); } } return input; }
/** Forced raw will not work if using this method */ String detectRawFromAbstract(String abstractName) { for (Naming naming : scheme.typeAbstract) { String raw = naming.detect(abstractName); if (!raw.isEmpty()) { // TBD is there a way to raise abstraction return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, raw); } } return abstractName; }
static String toParamName(final UriTemplate uri, final String delimiter, final String suffix) { return StringUtils.capitalize(uri.getComponents().stream().map( uriTemplatePart -> { if (uriTemplatePart instanceof Expression) { return ((Expression)uriTemplatePart).getVarSpecs().stream() .map(s -> delimiter + StringUtils.capitalize(s.getVariableName()) + suffix).collect(Collectors.joining()); } return CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, uriTemplatePart.toString().replace("/", "-")); } ).collect(Collectors.joining())).replaceAll("[^\\p{L}\\p{Nd}]+", ""); }
@Override public void addCompletions( @NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result ) { final PsiElement element = parameters.getPosition(); final List<PhpClass> elementClasses = PhpClassUtil.resolve(element.getParent()); if (elementClasses.isEmpty()) { return; } for (final PhpClass elementClass : elementClasses) { if (PhpClassUtil.findSuperOfType(elementClass, LaravelClasses.ELOQUENT_MODEL.toString()) == null) { return; } for (final Method method : elementClass.getMethods()) { if (method.getName().startsWith("scope")) { final String methodSliced = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, method.getName().substring(5)); result.addElement(new CompletionContributorLookupElement(element, method, methodSliced)); } } } }
@Override public Property getProperty(Class<? extends Object> type, String name) throws IntrospectionException { if (name.indexOf('-') > -1) { name = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, name); } return super.getProperty(type, name); }
public boolean isValid(PersistentEntity entity, ConstraintValidatorContext constraint) { final String value = (String) Reflection.get(entity, property); if (isBlank(value)) { return true; } String columnName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, property); String query = "select count(id) from " + getTableName(entity) + " where " + columnName + " = :value and id != :id"; Query q = repository.query(query).setParameter("value", value).setParameter("id", entity.getId()); return repository.count(q) == 0; }
@JsonCreator public Feature(String featureName) { if (featureName.startsWith("http://") || featureName.startsWith("https://")) { this.imageApiFeature = ImageApiFeature.OTHER; this.customFeature = URI.create(featureName); } else { String name = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, featureName); name = name.replaceAll("([A-Z])(\\d)", "$1_$2"); this.imageApiFeature = ImageApiFeature.valueOf(name); this.customFeature = null; } }
@Override public void configure(CommandLine cli) { CommandLine healthCli = new CommandLine(new HelpAwareContainerPicocliCommand() {}); for (Map.Entry<String, HealthIndicator> entry : healthIndicators.entrySet()) { Matcher matcher = HEALTH_PATTERN.matcher(entry.getKey()); if (matcher.matches()) { String name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, matcher.group(1)); healthCli.addSubcommand(name, new PrintCommand(entry.getValue().health())); } else { logger.warn("Unable to determine a correct name for given indicator: \"{}\", skip it!", entry.getKey()); } } cli.addSubcommand("health", healthCli); }
private static void schrijfStamgegevenWaarde(final BerichtWriter berichtWriter, final Map<String, Object> stringObjectMap, final AttribuutElement attribuutElement) { final Object waarde = stringObjectMap .get(attribuutElement.getElement().getElementWaarde().getIdentdb().toLowerCase()); if (waarde == null || StringUtils.isEmpty(waarde.toString())) { return; } final String waardeFormatted = bepaalWaarde(waarde, attribuutElement); final String lowerCamelCaseAttribuutNaam = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, attribuutElement.getXmlNaam()); berichtWriter.element(lowerCamelCaseAttribuutNaam, StringUtils.defaultString(waardeFormatted)); }
@Override public IntensionDai.Record extract(WriteContext context, DeclareIntensionApi.Form form) throws NotFound, Panic, BadRequest { NotBadRequest.from(form); form.setField(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getField())); IntensionDai.Record record = ValueMapping.from(IntensionDai.Record.class, context, form); record.setId(String.valueOf(idgen.born())); record.setCommit(HashTools.hashHex(record)); record.setBeginTime(new Date()); return NotBadResponse.of(record); }
public static DCashFund convertCash(Value row) { DCashFund cashFund = new DCashFund(); for (Value_ value : row.getValue()) { try { String methodName = "set" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, value.getName()); switch (value.getName()) { case "id": int intValue = (int) (double) value.getValue(); DCashFund.class.getMethod(methodName, int.class).invoke(cashFund, intValue); break; case "currencyCode": String stringValue = (String) value.getValue(); DCashFund.class.getMethod(methodName, String.class).invoke(cashFund, stringValue); break; case "value": BigDecimal bdValue = new BigDecimal((double) value.getValue()); if (bdValue.scale() > 4) { bdValue = bdValue.setScale(4, RoundingMode.HALF_UP); } DCashFund.class.getMethod(methodName, BigDecimal.class).invoke(cashFund, bdValue); break; } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { DLog.DEGIRO.error("Error while setting value of cash fund", e); } } return cashFund; }
@Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String variableName = DefaultNamePolicy.format(name, CaseFormat.UPPER_CAMEL); if (Strings.isNullOrEmpty(variableName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name"); } try { final PsiType psiType = typeConverter.apply(type); return GenerateMembersUtil.suggestGetterName(variableName, psiType, project); } catch (IncorrectOperationException e) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a method name", e); } }
@Override public List<InstanceDai.Value> extract(WriteContext context, RefreshEntireValueApi.SubIdForm form, MultiValueMap<String, IntensionDai.Record> dict) { List<InstanceDai.Value> instances = new ArrayList<>(); Date now = new Date(); Map<String, List<String>> map = form.getMap(); for (String field : map.keySet()) { String dictField = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, field); IntensionDai.Record record = dict.getFirst(dictField); if (record == null) { logger.warn("cannot find field [{}]", field); continue; } String intId = record.getId(); String[] values = cleanUpValues(map.get(field).toArray(new RefreshPartialValueApi.Value[0])); InstanceDai.Value value = ValueMapping.from(InstanceDai.Value.class, context, form); value.setId(String.valueOf(setgen.born())); value.setExtId(record.getExtId()); value.setIntId(intId); value.setField(dictField); value.setValues(values); value.setBeginTime(now); value.setCommit(HashTools.hashHex(value)); instances.add(value); } return instances; }
public StandardCssObject() { name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, this.getClass().getSimpleName()); obsolete = false; experimental = false; vendors = new HashSet<>(); links = new ArrayList<>(); }
@Override public ExtensionDai.Record extract(WriteContext context, DeclareExtensionApi.CommitForm form) throws BadRequest, Panic { NotBadRequest.from(form); form.setGroup(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getGroup())); form.setName(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getName())); form.setTree(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getTree())); form.setVisibility(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getVisibility())); ExtensionDai.Record record = ValueMapping.from(ExtensionDai.Record.class, form, context); hash(record); record.setId(String.valueOf(idgen.born())); return NotBadResponse.of(record); }
@Override public TypeSpec caseStringType(final StringType stringType) { if (stringType.getEnum().isEmpty()) { return null; } else { final TypeSpec.Builder enumBuilder = TypeSpec.enumBuilder(stringType.getName()); enumBuilder.addModifiers(Modifier.PUBLIC); final Converter<String, String> enumCamelConverter = CaseFormat.LOWER_CAMEL .converterTo(CaseFormat.UPPER_UNDERSCORE); final Converter<String, String> enumHyphenConverter = CaseFormat.LOWER_HYPHEN .converterTo(CaseFormat.UPPER_UNDERSCORE); final List<String> enumStringValues = stringType.getEnum().stream() .filter(StringInstance.class::isInstance) .map(StringInstance.class::cast) .map(StringInstance::getValue) .collect(Collectors.toList()); for (final String enumValue : enumStringValues) { final String enumLiteral = enumValue.contains("-") ? enumHyphenConverter.convert(enumValue) : enumCamelConverter.convert(enumValue); enumBuilder.addEnumConstant(enumLiteral); } return enumBuilder.build(); } }
@Override public String toString() { return mSourceLocation.print(false) + ":" + mLineNumber + ":" + mColumnNumber + " " + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, mSeverity.toString()) + ":\n\t" + mLog; }
@Override public List<InstanceDai.Value> extract(WriteContext context, RefreshPartialValueApi.SubIdForm form, MultiValueMap<String, IntensionDai.Record> dict) { List<InstanceDai.Value> values = new ArrayList<>(); Date now = new Date(); String dictField = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getField()); IntensionDai.Record record = dict.getFirst(dictField); if (record == null) { logger.warn("cannot find field [{}]", form.getField()); return Collections.emptyList(); } String intId = record.getId(); String[] vs = cleanUpValues(form.getValues()); for (RefreshPartialValueApi.Value value : form.getValues()) { InstanceDai.Value instance = ValueMapping.from(InstanceDai.Value.class, context, form); instance.setId(String.valueOf(setgen.born())); instance.setExtId(record.getExtId()); instance.setIntId(intId); instance.setField(dictField); if (value.getGlimpseId() != null) { instance.setGlimpseId(value.getGlimpseId()); } instance.setValues(vs); instance.setBeginTime(now); instance.setCommit(HashTools.hashHex(instance)); values.add(instance); } return values; }
@Nonnull @Override public String convert(@Nonnull String name, @Nonnull TypeName type) { final String propertyName = DefaultNamePolicy.format(name, CaseFormat.LOWER_CAMEL); final String fieldName = codeStyleManager.propertyNameToVariableName(propertyName, VariableKind.FIELD); if (Strings.isNullOrEmpty(fieldName)) { throw new IllegalArgumentException("Cannot convert '" + name + "' to a field name"); } return fieldName; }
public static String humanizeString(String name, String suffixToRemove) { if (suffixToRemove != null && name.endsWith(suffixToRemove)) { name = name.substring(0, name.length() - suffixToRemove.length()); } name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name).replace("_", " "); return name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase(); }
private List<Map<String, Object>> convertTabularData(JsonUgcResponse response) { List<Map<String, Object>> result = new ArrayList<>(); List<String> columnNames = response.getColumns(); for (List<Object> row : response.getData()) { Map<String, Object> resultRow = new LinkedHashMap<>(); for (int i = 0; i < row.size(); i++) { resultRow.put(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, columnNames.get(i)), row.get(i)); } result.add(resultRow); } return result; }
private List<EmbedObject> getRoleInfo(IRole role, boolean withGuild, CommandContext context) { List<EmbedObject> embeds = new ArrayList<>(); if (role == null) { return embeds; } Color color = role.getColor(); String hex = String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()); String perms = role.getPermissions().stream() .map(Enum::toString) .map(p -> CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, p)) .collect(Collectors.joining(", ")); boolean hoisted = role.isHoisted(); boolean mentionable = role.isMentionable(); boolean managed = role.isManaged(); boolean isEveryone = role.isEveryoneRole(); EmbedBuilder builder = authoredEmbed(context.getMessage()) .withColor(role.getColor() != null ? role.getColor() : new Color(0)) .appendField("Role", mentionBuster(role.getName()), false) .appendField("ID", "<" + role.getStringID() + ">", false) .appendField("Color", hex, true) .appendField("Position", "" + role.getPosition(), true) .appendField("Created", withRelative(systemToInstant(role.getCreationDate())), false); if (!isEveryone && (hoisted || mentionable || managed)) { builder.appendField("Tags", Stream.of((hoisted ? "hoisted" : ""), (mentionable ? "mentionable" : ""), (managed ? "managed" : "")) .filter(s -> !s.isEmpty()) .collect(Collectors.joining(", ")), false); } builder.appendField("Permissions", perms, true); embeds.add(builder.build()); if (isEveryone || withGuild) { embeds.add(getGuildInfo(role.getGuild())); } return embeds; }
private static String getJavaOuterClassname( DescriptorProtos.FileDescriptorProto fileDescriptor, DescriptorProtos.FileOptions fileOptions) { if (fileOptions.hasJavaOuterClassname()) { return fileOptions.getJavaOuterClassname(); } // If the outer class name is not explicitly defined, then we take the proto filename, strip its extension, // and convert it from snake case to camel case. String filename = fileDescriptor.getName().substring(0, fileDescriptor.getName().length() - ".proto".length()); filename = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, filename); return appendOuterClassSuffix(filename, fileDescriptor); }
private static String joinCamelCase(Iterable<String> parts) { return CaseFormat.LOWER_UNDERSCORE.to( CaseFormat.LOWER_CAMEL, JOINER_UNDERSCORE.join(parts)); }
private static Iterable<String> splitCamelCase(String name) { return SPLITTER_UNDERSCORE.split( CaseFormat.LOWER_CAMEL.to( CaseFormat.LOWER_UNDERSCORE, name)); }
private String generateProperName(EncodedElement element) { if (element.isImplField()) { return names.var; } if (element.isExpose()) { return names.get; } if (element.standardNaming() != StandardNaming.NONE) { switch (element.standardNaming()) { case GET: return names.get; case INIT: return names.init; case ADD: return names.add(); case ADD_ALL: return names.addAll(); case PUT: return names.put(); case PUT_ALL: return names.putAll(); case WITH: return names.with; default: } } if (isDefaultUnspecifiedValue(element)) { if (element.isCopy()) { return names.with; } if (element.isInit()) { return names.init; } } if (element.isStaticField() && element.isFinal()) { String base = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, rawName()); return element.naming().apply(base); } return names.apply(element.naming(), element.depluralize()); }