use of org.apache.commons.lang3.StringUtils.capitalize in project spring-roo by spring-projects.
the class RepositoryJpaCustomImplMetadataProviderImpl method buildFieldNamesMap.
/**
* Build a Map<String, String> with field names and "path" field names
* and adds it to the typesFieldMaps Map.
*
* @param entity
* @param projection
* @param entityProjectionAnnotation
* @param typesFieldMaps
*/
private void buildFieldNamesMap(JavaType entity, JavaType projection, AnnotationMetadata entityProjectionAnnotation, Map<JavaType, List<Pair<String, String>>> typesFieldMaps) {
List<Pair<String, String>> projectionFieldNames = new ArrayList<Pair<String, String>>();
if (!typesFieldMaps.containsKey(projection)) {
AnnotationAttributeValue<?> projectionFields = entityProjectionAnnotation.getAttribute("fields");
if (projectionFields != null) {
@SuppressWarnings("unchecked") List<StringAttributeValue> values = (List<StringAttributeValue>) projectionFields.getValue();
// Get entity name as a variable name for building constructor expression
String entityVariableName = StringUtils.uncapitalize(entity.getSimpleTypeName());
for (StringAttributeValue field : values) {
String[] splittedByDot = StringUtils.split(field.getValue(), ".");
StringBuffer propertyName = new StringBuffer();
for (int i = 0; i < splittedByDot.length; i++) {
if (i == 0) {
propertyName.append(splittedByDot[i]);
} else {
propertyName.append(StringUtils.capitalize(splittedByDot[i]));
}
}
String pathName = entityVariableName.concat(".").concat(field.getValue());
projectionFieldNames.add(Pair.of(propertyName.toString(), pathName));
typesFieldMaps.put(projection, projectionFieldNames);
}
}
}
}
use of org.apache.commons.lang3.StringUtils.capitalize in project FoodCraft-Reloaded by LasmGratel.
the class RegisterLoader method detectAndRegisterLiqueur.
public void detectAndRegisterLiqueur(RegistryEvent.Register<Item> event) {
event.getRegistry().getKeys().stream().filter(s -> s.getResourcePath().contains("liqueur")).map(ForgeRegistries.ITEMS::getValue).collect(Collectors.toList()).forEach(liqueur -> {
for (LiqueurType liqueurType : LiqueurTypes.values()) {
if (liqueurType == LiqueurTypes.NORMAL)
continue;
ItemGeneratedLiqueur typedLiqueur = new ItemGeneratedLiqueur(MathHelper.floor(liqueurType.getHealModifier() * ((ItemFood) liqueur).getHealAmount(new ItemStack(liqueur))));
typedLiqueur.setLiqueurType(liqueurType);
typedLiqueur.setItemStackDisplayNameCallback(liqueur::getItemStackDisplayName);
typedLiqueur.setRegistryName(liqueur.getRegistryName().getResourceDomain(), liqueurType.getUnlocalizedName() + "_" + liqueur.getRegistryName().getResourcePath());
typedLiqueur.setUnlocalizedName(liqueur.getUnlocalizedName());
event.getRegistry().register(typedLiqueur);
OreDictionary.registerOre("listAll" + StringUtils.capitalize(liqueurType.getUnlocalizedName()) + "liqueur", typedLiqueur);
OreDictionary.registerOre("listAllliqueur", typedLiqueur);
OreDictionary.registerOre("listAllfoods", typedLiqueur);
if (liqueur instanceof CustomModelMasking)
FoodCraftReloadedMod.getLoader(LiqueurLoader.class).get().getLiqueurCustomModelMap().put(typedLiqueur, (CustomModelMasking) liqueur);
}
});
}
use of org.apache.commons.lang3.StringUtils.capitalize in project apps-android-wikipedia by wikimedia.
the class ShareHandler method shareSnippet.
private void shareSnippet(@NonNull CharSequence input) {
final String selectedText = StringUtil.sanitizeText(input.toString());
final PageTitle title = fragment.getTitle();
final String leadImageNameText = fragment.getPage().getPageProperties().getLeadImageName() != null ? fragment.getPage().getPageProperties().getLeadImageName() : "";
final PageTitle imageTitle = new PageTitle(Namespace.FILE.toLegacyString(), leadImageNameText, title.getWikiSite());
disposables.add(ServiceFactory.get(title.getWikiSite()).getImageExtMetadata(imageTitle.getPrefixedText()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).map(response -> {
// noinspection ConstantConditions
MwQueryPage page = response.query().pages().get(0);
return page.imageInfo() != null && page.imageInfo().getMetadata() != null ? new ImageLicense(page.imageInfo().getMetadata()) : new ImageLicense();
}).subscribe(imageLicense -> {
final Bitmap snippetBitmap = SnippetImage.getSnippetImage(fragment.requireContext(), fragment.getLeadImageBitmap(), title.getDisplayText(), fragment.getPage().isMainPage() ? "" : StringUtils.capitalize(title.getDescription()), selectedText, imageLicense);
fragment.showBottomSheet(new PreviewDialog(fragment.getContext(), snippetBitmap, title, selectedText, funnel));
}, caught -> {
// If we failed to get license info for the lead image, just share the text
PreviewDialog.shareAsText(fragment.requireContext(), title, selectedText, funnel);
L.e("Error fetching image license info for " + title.getDisplayText(), caught);
}));
}
use of org.apache.commons.lang3.StringUtils.capitalize in project oap by oaplatform.
the class UniqueField method check.
@Override
@SuppressWarnings("unchecked")
public void check(T object, Storage<T> storage, Function<T, String> id) throws ConstraintException {
val idValue = id.apply(object);
val value = valueFunc.apply(object);
if (storage.select().filter(obj -> filter.test(object, obj)).anyMatch(itemObject -> equals(value, valueFunc.apply(itemObject)) && !idValue.equals(id.apply(itemObject)))) {
throw new ConstraintException(StringUtils.capitalize(type) + " '" + value + "' already exists.");
}
}
use of org.apache.commons.lang3.StringUtils.capitalize in project oap by oaplatform.
the class Linker method linkListeners.
@SuppressWarnings("unchecked")
private void linkListeners(Module.Service service, Object instance) {
service.listen.forEach((listener, reference) -> {
log.debug("setting " + service.name + " to listen to " + reference + " with listener " + listener);
String methodName = "add" + StringUtils.capitalize(listener) + "Listener";
Object linked = kernel.service(linkedServiceName(reference));
if (linked == null)
throw new ApplicationException("for " + service.name + " listening object " + reference + " is not found");
Optionals.fork(Reflect.reflect(linked.getClass()).method(methodName)).ifPresent(m -> m.invoke(linked, instance)).ifAbsentThrow(() -> new ReflectException("listener " + listener + " should have method " + methodName + " in " + reference));
});
}
Aggregations