Java Code Examples for lombok.experimental.Accessors#fluent()
The following examples show how to use
lombok.experimental.Accessors#fluent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HandlerUtil.java From EasyMPermission with MIT License | 6 votes |
public static boolean shouldReturnThis0(AnnotationValues<Accessors> accessors, AST<?, ?, ?> ast) { boolean chainForced = accessors.isExplicit("chain"); boolean fluentForced = accessors.isExplicit("fluent"); Accessors instance = accessors.getInstance(); boolean chain = instance.chain(); boolean fluent = instance.fluent(); if (chainForced) return chain; if (!chainForced) { Boolean chainConfig = ast.readConfiguration(ConfigurationKeys.ACCESSORS_CHAIN); if (chainConfig != null) return chainConfig; } if (!fluentForced) { Boolean fluentConfig = ast.readConfiguration(ConfigurationKeys.ACCESSORS_FLUENT); if (fluentConfig != null) fluent = fluentConfig; } return chain || fluent; }
Example 2
Source File: HandlerUtil.java From EasyMPermission with MIT License | 5 votes |
private static String toAccessorName(AST<?, ?, ?> ast, AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean, String booleanPrefix, String normalPrefix, boolean adhereToFluent) { fieldName = fieldName.toString(); if (fieldName.length() == 0) return null; if (Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.GETTER_CONSEQUENT_BOOLEAN))) isBoolean = false; boolean explicitPrefix = accessors != null && accessors.isExplicit("prefix"); boolean explicitFluent = accessors != null && accessors.isExplicit("fluent"); Accessors ac = (explicitPrefix || explicitFluent) ? accessors.getInstance() : null; List<String> prefix = explicitPrefix ? Arrays.asList(ac.prefix()) : ast.readConfiguration(ConfigurationKeys.ACCESSORS_PREFIX); boolean fluent = explicitFluent ? ac.fluent() : Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.ACCESSORS_FLUENT)); fieldName = removePrefix(fieldName, prefix); if (fieldName == null) return null; String fName = fieldName.toString(); if (adhereToFluent && fluent) return fName; if (isBoolean && fName.startsWith("is") && fieldName.length() > 2 && !Character.isLowerCase(fieldName.charAt(2))) { // The field is for example named 'isRunning'. return booleanPrefix + fName.substring(2); } return buildAccessorName(isBoolean ? booleanPrefix : normalPrefix, fName); }
Example 3
Source File: HandlerUtil.java From EasyMPermission with MIT License | 5 votes |
private static List<String> toAllAccessorNames(AST<?, ?, ?> ast, AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean, String booleanPrefix, String normalPrefix, boolean adhereToFluent) { if (Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.GETTER_CONSEQUENT_BOOLEAN))) isBoolean = false; if (!isBoolean) { String accessorName = toAccessorName(ast, accessors, fieldName, false, booleanPrefix, normalPrefix, adhereToFluent); return (accessorName == null) ? Collections.<String>emptyList() : Collections.singletonList(accessorName); } boolean explicitPrefix = accessors != null && accessors.isExplicit("prefix"); boolean explicitFluent = accessors != null && accessors.isExplicit("fluent"); Accessors ac = (explicitPrefix || explicitFluent) ? accessors.getInstance() : null; List<String> prefix = explicitPrefix ? Arrays.asList(ac.prefix()) : ast.readConfiguration(ConfigurationKeys.ACCESSORS_PREFIX); boolean fluent = explicitFluent ? ac.fluent() : Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.ACCESSORS_FLUENT)); fieldName = removePrefix(fieldName, prefix); if (fieldName == null) return Collections.emptyList(); List<String> baseNames = toBaseNames(fieldName, isBoolean, fluent); Set<String> names = new HashSet<String>(); for (String baseName : baseNames) { if (adhereToFluent && fluent) { names.add(baseName); } else { names.add(buildAccessorName(normalPrefix, baseName)); if (!normalPrefix.equals(booleanPrefix)) names.add(buildAccessorName(booleanPrefix, baseName)); } } return new ArrayList<String>(names); }