2022-03-01 22:12:19 +00:00
package lombok.core.handlers ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Collections ;
import java.util.HashSet ;
import java.util.Iterator ;
import java.util.List ;
import java.util.regex.Matcher ;
import java.util.regex.Pattern ;
import lombok.AllArgsConstructor ;
import lombok.ConfigurationKeys ;
import lombok.Data ;
import lombok.EqualsAndHashCode ;
import lombok.Getter ;
import lombok.NoArgsConstructor ;
import lombok.RequiredArgsConstructor ;
import lombok.Setter ;
import lombok.ToString ;
import lombok.Value ;
import lombok.With ;
import lombok.core.AST ;
import lombok.core.AnnotationValues ;
import lombok.core.JavaIdentifiers ;
import lombok.core.LombokNode ;
import lombok.core.configuration.AllowHelper ;
import lombok.core.configuration.CheckerFrameworkVersion ;
import lombok.core.configuration.ConfigurationKey ;
import lombok.core.configuration.FlagUsageType ;
import lombok.experimental.Accessors ;
import lombok.experimental.FieldDefaults ;
2022-03-10 09:16:07 +00:00
/* loaded from: com.discord-118108.apk:lombok/core/handlers/HandlerUtil.SCL.lombok */
2022-03-01 22:12:19 +00:00
public class HandlerUtil {
public static final String DEFAULT_EXCEPTION_FOR_NON_NULL = " java.lang.NullPointerException " ;
public static final List < String > NONNULL_ANNOTATIONS = Collections . unmodifiableList ( Arrays . asList ( " androidx.annotation.NonNull " , " android.support.annotation.NonNull " , " com.sun.istack.internal.NotNull " , " edu.umd.cs.findbugs.annotations.NonNull " , " javax.annotation.Nonnull " , " lombok.NonNull " , " org.checkerframework.checker.nullness.qual.NonNull " , " org.eclipse.jdt.annotation.NonNull " , " org.eclipse.jgit.annotations.NonNull " , " org.jetbrains.annotations.NotNull " , " org.jmlspecs.annotation.NonNull " , " org.netbeans.api.annotations.common.NonNull " , " org.springframework.lang.NonNull " ) ) ;
public static final List < String > BASE_COPYABLE_ANNOTATIONS = Collections . unmodifiableList ( Arrays . asList ( " androidx.annotation.NonNull " , " androidx.annotation.Nullable " , " android.support.annotation.NonNull " , " android.support.annotation.Nullable " , " edu.umd.cs.findbugs.annotations.NonNull " , " edu.umd.cs.findbugs.annotations.Nullable " , " edu.umd.cs.findbugs.annotations.UnknownNullness " , " javax.annotation.CheckForNull " , " javax.annotation.Nonnull " , " javax.annotation.Nullable " , " lombok.NonNull " , " org.jmlspecs.annotation.NonNull " , " org.jmlspecs.annotation.Nullable " , " org.checkerframework.checker.compilermsgs.qual.CompilerMessageKey " , " org.checkerframework.checker.compilermsgs.qual.CompilerMessageKeyBottom " , " org.checkerframework.checker.compilermsgs.qual.UnknownCompilerMessageKey " , " org.checkerframework.checker.fenum.qual.AwtAlphaCompositingRule " , " org.checkerframework.checker.fenum.qual.AwtColorSpace " , " org.checkerframework.checker.fenum.qual.AwtCursorType " , " org.checkerframework.checker.fenum.qual.AwtFlowLayout " , " org.checkerframework.checker.fenum.qual.Fenum " , " org.checkerframework.checker.fenum.qual.FenumBottom " , " org.checkerframework.checker.fenum.qual.FenumTop " , " org.checkerframework.checker.fenum.qual.PolyFenum " , " org.checkerframework.checker.fenum.qual.SwingBoxOrientation " , " org.checkerframework.checker.fenum.qual.SwingCompassDirection " , " org.checkerframework.checker.fenum.qual.SwingElementOrientation " , " org.checkerframework.checker.fenum.qual.SwingHorizontalOrientation " , " org.checkerframework.checker.fenum.qual.SwingSplitPaneOrientation " , " org.checkerframework.checker.fenum.qual.SwingTextOrientation " , " org.checkerframework.checker.fenum.qual.SwingTitleJustification " , " org.checkerframework.checker.fenum.qual.SwingTitlePosition " , " org.checkerframework.checker.fenum.qual.SwingVerticalOrientation " , " org.checkerframework.checker.formatter.qual.Format " , " org.checkerframework.checker.formatter.qual.FormatBottom " , " org.checkerframework.checker.formatter.qual.InvalidFormat " , " org.checkerframework.checker.guieffect.qual.AlwaysSafe " , " org.checkerframework.checker.guieffect.qual.PolyUI " , " org.checkerframework.checker.guieffect.qual.UI " , " org.checkerframework.checker.i18nformatter.qual.I18nFormat " , " org.checkerframework.checker.i18nformatter.qual.I18nFormatBottom " , " org.checkerframework.checker.i18nformatter.qual.I18nFormatFor " , " org.checkerframework.checker.i18nformatter.qual.I18nInvalidFormat " , " org.checkerframework.checker.i18nformatter.qual.I18nUnknownFormat " , " org.checkerframework.checker.i18n.qual.LocalizableKey " , " org.checkerframework.checker.i18n.qual.LocalizableKeyBottom " , " org.checkerframework.checker.i18n.qual.Localized " , " org.checkerframework.checker.i18n.qual.UnknownLocalizableKey " , " org.checkerframework.checker.i18n.qual.UnknownLocalized " , " org.checkerframework.checker.index.qual.GTENegativeOne " , " org.checkerframework.checker.index.qual.IndexFor " , " org.checkerframework.checker.index.qual.IndexOrHigh " , " org.checkerframework.checker.index.qual.IndexOrLow " , " org.checkerframework.checker.index.qual.LengthOf " , " org.checkerframework.checker.index.qual.LessThan " , " org.checkerframework.checker.index.qual.LessThanBottom " , " org.checkerframework.checker.index.qual.LessThanUnknown " , " org.checkerframework.checker.index.qual.LowerBoundBottom " , " org.checkerframework.checker.index.qual.LowerBoundUnknown " , " org.checkerframework.checker.index.qual.LTEqLengthOf " , " org.checkerframework.checker.index.qual.LTLengthOf " , " org.checkerframework.checker.index.qual.LTOMLengthOf " , " org.checkerframework.checker.index.qual.NegativeIndexFor " , " org.checkerframework.checker.index.qual.NonNegative " , " org.checkerframework.checker.index.qual.PolyIndex " , " org.checkerframework.checker.index.qual.PolyLength " , " org.checkerframework.checker.index.qual.PolyLowerBound " , " org.checkerframework.checker.index.qual.PolySameLen " , " org.checkerframework.checker.index.qual.PolyUpperBound " , " org.checkerframework.checker.index.qual.Positive " , " org.checkerframework.checker.index.qual.SameLen " , " org.checkerframework.checker.index.qual.SameLenBottom " , " org.checkerframework.c
public static final List < String > COPY_TO_SETTER_ANNOTATIONS = Collections . unmodifiableList ( Arrays . asList ( " com.fasterxml.jackson.annotation.JacksonInject " , " com.fasterxml.jackson.annotation.JsonAlias " , " com.fasterxml.jackson.annotation.JsonFormat " , " com.fasterxml.jackson.annotation.JsonIgnore " , " com.fasterxml.jackson.annotation.JsonIgnoreProperties " , " com.fasterxml.jackson.annotation.JsonProperty " , " com.fasterxml.jackson.annotation.JsonSetter " , " com.fasterxml.jackson.annotation.JsonSubTypes " , " com.fasterxml.jackson.annotation.JsonTypeInfo " , " com.fasterxml.jackson.annotation.JsonView " , " com.fasterxml.jackson.databind.annotation.JsonDeserialize " , " com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty " ) ) ;
public static final List < String > COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS = Collections . unmodifiableList ( Arrays . asList ( " com.fasterxml.jackson.annotation.JsonAnySetter " ) ) ;
public static final List < String > JACKSON_COPY_TO_BUILDER_ANNOTATIONS = Collections . unmodifiableList ( Arrays . asList ( " com.fasterxml.jackson.annotation.JsonAutoDetect " , " com.fasterxml.jackson.annotation.JsonFormat " , " com.fasterxml.jackson.annotation.JsonIgnoreProperties " , " com.fasterxml.jackson.annotation.JsonIgnoreType " , " com.fasterxml.jackson.annotation.JsonPropertyOrder " , " com.fasterxml.jackson.annotation.JsonRootName " , " com.fasterxml.jackson.annotation.JsonSubTypes " , " com.fasterxml.jackson.annotation.JsonTypeInfo " , " com.fasterxml.jackson.annotation.JsonTypeName " , " com.fasterxml.jackson.annotation.JsonView " , " com.fasterxml.jackson.databind.annotation.JsonNaming " ) ) ;
public static final List < String > INVALID_ON_BUILDERS = Collections . unmodifiableList ( Arrays . asList ( Getter . class . getName ( ) , Setter . class . getName ( ) , With . class . getName ( ) , " lombok.experimental.Wither " , ToString . class . getName ( ) , EqualsAndHashCode . class . getName ( ) , RequiredArgsConstructor . class . getName ( ) , AllArgsConstructor . class . getName ( ) , NoArgsConstructor . class . getName ( ) , Data . class . getName ( ) , Value . class . getName ( ) , " lombok.experimental.Value " , FieldDefaults . class . getName ( ) ) ) ;
private static final Pattern PRIMITIVE_WRAPPER_TYPE_NAME_PATTERN = Pattern . compile ( " ^(?:java \\ .lang \\ .)?(?:Boolean|Byte|Short|Integer|Long|Float|Double|Character)$ " ) ;
private static final Pattern SECTION_FINDER = Pattern . compile ( " ^ \\ s* \\ ** \\ s*[-*][-*]+ \\ s*([GS]ETTER|WITH(?:ER)?) \\ s*[-*][-*]+ \\ s* \\ ** \\ s*$ " , 10 ) ;
private static final Pattern LINE_BREAK_FINDER = Pattern . compile ( " ( \\ r? \\ n)? " ) ;
private static final Pattern FIND_RETURN = Pattern . compile ( " ^ \\ s* \\ ** \\ s*@returns? \\ s+.*$ " , 10 ) ;
2022-03-10 09:16:07 +00:00
/* loaded from: com.discord-118108.apk:lombok/core/handlers/HandlerUtil$FieldAccess.SCL.lombok */
2022-03-01 22:12:19 +00:00
public enum FieldAccess {
GETTER ,
PREFER_FIELD ,
ALWAYS_FIELD
}
private HandlerUtil ( ) {
}
public static int primeForHashcode ( ) {
return 59 ;
}
public static int primeForTrue ( ) {
return 79 ;
}
public static int primeForFalse ( ) {
return 97 ;
}
public static int primeForNull ( ) {
return 43 ;
}
public static boolean checkName ( String str , String str2 , LombokNode < ? , ? , ? > lombokNode ) {
if ( str2 . isEmpty ( ) ) {
lombokNode . addError ( String . valueOf ( str ) + " cannot be the empty string. " ) ;
return false ;
} else if ( JavaIdentifiers . isValidJavaIdentifier ( str2 ) ) {
return true ;
} else {
lombokNode . addError ( String . valueOf ( str ) + " must be a valid java identifier. " ) ;
return false ;
}
}
public static String autoSingularize ( String str ) {
return Singulars . autoSingularize ( str ) ;
}
public static void handleFlagUsage ( LombokNode < ? , ? , ? > lombokNode , ConfigurationKey < FlagUsageType > configurationKey , String str ) {
FlagUsageType flagUsageType = ( FlagUsageType ) lombokNode . getAst ( ) . readConfiguration ( configurationKey ) ;
if ( flagUsageType = = null & & AllowHelper . isAllowable ( configurationKey ) ) {
lombokNode . addError ( " Use of " + str + " is disabled by default. Please add ' " + configurationKey . getKeyName ( ) + " = " + FlagUsageType . ALLOW + " ' to 'lombok.config' if you want to enable is. " ) ;
}
if ( flagUsageType ! = null ) {
String str2 = " Use of " + str + " is flagged according to lombok configuration. " ;
if ( flagUsageType = = FlagUsageType . WARNING ) {
lombokNode . addWarning ( str2 ) ;
} else if ( flagUsageType = = FlagUsageType . ERROR ) {
lombokNode . addError ( str2 ) ;
}
}
}
public static boolean shouldAddGenerated ( LombokNode < ? , ? , ? > lombokNode ) {
Boolean bool = ( Boolean ) lombokNode . getAst ( ) . readConfiguration ( ConfigurationKeys . ADD_JAVAX_GENERATED_ANNOTATIONS ) ;
return bool ! = null ? bool . booleanValue ( ) : Boolean . TRUE . equals ( lombokNode . getAst ( ) . readConfiguration ( ConfigurationKeys . ADD_GENERATED_ANNOTATIONS ) ) ;
}
public static void handleExperimentalFlagUsage ( LombokNode < ? , ? , ? > lombokNode , ConfigurationKey < FlagUsageType > configurationKey , String str ) {
handleFlagUsage ( lombokNode , configurationKey , str , ConfigurationKeys . EXPERIMENTAL_FLAG_USAGE , " any lombok.experimental feature " ) ;
}
public static void handleFlagUsage ( LombokNode < ? , ? , ? > lombokNode , ConfigurationKey < FlagUsageType > configurationKey , String str , ConfigurationKey < FlagUsageType > configurationKey2 , String str2 ) {
String str3 ;
FlagUsageType flagUsageType ;
FlagUsageType flagUsageType2 = ( FlagUsageType ) lombokNode . getAst ( ) . readConfiguration ( configurationKey ) ;
FlagUsageType flagUsageType3 = ( FlagUsageType ) lombokNode . getAst ( ) . readConfiguration ( configurationKey2 ) ;
if ( flagUsageType2 = = FlagUsageType . ERROR ) {
flagUsageType = flagUsageType2 ;
str3 = str ;
} else if ( flagUsageType3 = = FlagUsageType . ERROR ) {
flagUsageType = flagUsageType3 ;
str3 = str2 ;
} else if ( flagUsageType2 = = FlagUsageType . WARNING ) {
flagUsageType = flagUsageType2 ;
str3 = str ;
} else {
flagUsageType = flagUsageType3 ;
str3 = str2 ;
}
if ( flagUsageType ! = null ) {
String str4 = " Use of " + str3 + " is flagged according to lombok configuration. " ;
if ( flagUsageType = = FlagUsageType . WARNING ) {
lombokNode . addWarning ( str4 ) ;
} else if ( flagUsageType = = FlagUsageType . ERROR ) {
lombokNode . addError ( str4 ) ;
}
}
}
public static boolean shouldReturnThis0 ( AnnotationValues < Accessors > annotationValues , AST < ? , ? , ? > ast ) {
Boolean bool ;
Boolean bool2 ;
boolean isExplicit = annotationValues . isExplicit ( " chain " ) ;
boolean isExplicit2 = annotationValues . isExplicit ( " fluent " ) ;
Accessors instance = annotationValues . getInstance ( ) ;
boolean chain = instance . chain ( ) ;
boolean fluent = instance . fluent ( ) ;
if ( isExplicit ) {
return chain ;
}
if ( ! isExplicit & & ( bool2 = ( Boolean ) ast . readConfiguration ( ConfigurationKeys . ACCESSORS_CHAIN ) ) ! = null ) {
return bool2 . booleanValue ( ) ;
}
if ( ! isExplicit2 & & ( bool = ( Boolean ) ast . readConfiguration ( ConfigurationKeys . ACCESSORS_FLUENT ) ) ! = null ) {
fluent = bool . booleanValue ( ) ;
}
return chain | | fluent ;
}
public static CharSequence removePrefix ( CharSequence charSequence , List < String > list ) {
if ( list = = null | | list . isEmpty ( ) ) {
return charSequence ;
}
String charSequence2 = charSequence . toString ( ) ;
Iterator < String > it = list . iterator ( ) ;
while ( it . hasNext ( ) ) {
String next = it . next ( ) ;
if ( next . length ( ) = = 0 ) {
return charSequence2 ;
}
if ( charSequence2 . length ( ) > next . length ( ) ) {
int i = 0 ;
while ( true ) {
if ( i > = next . length ( ) ) {
char charAt = charSequence2 . charAt ( next . length ( ) ) ;
if ( ! Character . isLetter ( next . charAt ( next . length ( ) - 1 ) ) | | ! Character . isLowerCase ( charAt ) ) {
return new StringBuilder ( ) . append ( Character . toLowerCase ( charAt ) ) . append ( ( Object ) charSequence2 . subSequence ( next . length ( ) + 1 , charSequence2 . length ( ) ) ) . toString ( ) ;
}
} else if ( charSequence2 . charAt ( i ) ! = next . charAt ( i ) ) {
break ;
} else {
i + + ;
}
}
}
}
return null ;
}
public static String toGetterName ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 ) {
return toAccessorName ( ast , annotationValues , charSequence , z2 , " is " , " get " , true ) ;
}
public static String toSetterName ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 ) {
return toAccessorName ( ast , annotationValues , charSequence , z2 , " set " , " set " , true ) ;
}
public static String toWithName ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 ) {
return toAccessorName ( ast , annotationValues , charSequence , z2 , " with " , " with " , false ) ;
}
public static String toWithByName ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 ) {
return String . valueOf ( toAccessorName ( ast , annotationValues , charSequence , z2 , " with " , " with " , false ) ) + " By " ;
}
private static String toAccessorName ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 , String str , String str2 , boolean z3 ) {
String charSequence2 = charSequence . toString ( ) ;
if ( charSequence2 . length ( ) = = 0 ) {
return null ;
}
if ( Boolean . TRUE . equals ( ast . readConfiguration ( ConfigurationKeys . GETTER_CONSEQUENT_BOOLEAN ) ) ) {
z2 = false ;
}
boolean z4 = annotationValues ! = null & & annotationValues . isExplicit ( " prefix " ) ;
boolean z5 = annotationValues ! = null & & annotationValues . isExplicit ( " fluent " ) ;
Accessors instance = ( z4 | | z5 ) ? annotationValues . getInstance ( ) : null ;
List asList = z4 ? Arrays . asList ( instance . prefix ( ) ) : ( List ) ast . readConfiguration ( ConfigurationKeys . ACCESSORS_PREFIX ) ;
boolean fluent = z5 ? instance . fluent ( ) : Boolean . TRUE . equals ( ast . readConfiguration ( ConfigurationKeys . ACCESSORS_FLUENT ) ) ;
CharSequence removePrefix = removePrefix ( charSequence2 , asList ) ;
if ( removePrefix = = null ) {
return null ;
}
String charSequence3 = removePrefix . toString ( ) ;
if ( z3 & & fluent ) {
return charSequence3 ;
}
if ( z2 & & charSequence3 . startsWith ( " is " ) & & removePrefix . length ( ) > 2 & & ! Character . isLowerCase ( removePrefix . charAt ( 2 ) ) ) {
return String . valueOf ( str ) + charSequence3 . substring ( 2 ) ;
}
return buildAccessorName ( z2 ? str : str2 , charSequence3 ) ;
}
public static List < String > toAllGetterNames ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 ) {
return toAllAccessorNames ( ast , annotationValues , charSequence , z2 , " is " , " get " , true ) ;
}
public static List < String > toAllSetterNames ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 ) {
return toAllAccessorNames ( ast , annotationValues , charSequence , z2 , " set " , " set " , true ) ;
}
public static List < String > toAllWithNames ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 ) {
return toAllAccessorNames ( ast , annotationValues , charSequence , z2 , " with " , " with " , false ) ;
}
public static List < String > toAllWithByNames ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 ) {
List < String > allAccessorNames = toAllAccessorNames ( ast , annotationValues , charSequence , z2 , " with " , " with " , false ) ;
if ( ! ( allAccessorNames instanceof ArrayList ) ) {
allAccessorNames = new ArrayList < > ( allAccessorNames ) ;
}
for ( int i = 0 ; i < allAccessorNames . size ( ) ; i + + ) {
allAccessorNames . set ( i , String . valueOf ( allAccessorNames . get ( i ) ) + " By " ) ;
}
return allAccessorNames ;
}
private static List < String > toAllAccessorNames ( AST < ? , ? , ? > ast , AnnotationValues < Accessors > annotationValues , CharSequence charSequence , boolean z2 , String str , String str2 , boolean z3 ) {
if ( Boolean . TRUE . equals ( ast . readConfiguration ( ConfigurationKeys . GETTER_CONSEQUENT_BOOLEAN ) ) ) {
z2 = false ;
}
if ( ! z2 ) {
String accessorName = toAccessorName ( ast , annotationValues , charSequence , false , str , str2 , z3 ) ;
return accessorName = = null ? Collections . emptyList ( ) : Collections . singletonList ( accessorName ) ;
}
boolean z4 = annotationValues ! = null & & annotationValues . isExplicit ( " prefix " ) ;
boolean z5 = annotationValues ! = null & & annotationValues . isExplicit ( " fluent " ) ;
Accessors instance = ( z4 | | z5 ) ? annotationValues . getInstance ( ) : null ;
List asList = z4 ? Arrays . asList ( instance . prefix ( ) ) : ( List ) ast . readConfiguration ( ConfigurationKeys . ACCESSORS_PREFIX ) ;
boolean fluent = z5 ? instance . fluent ( ) : Boolean . TRUE . equals ( ast . readConfiguration ( ConfigurationKeys . ACCESSORS_FLUENT ) ) ;
CharSequence removePrefix = removePrefix ( charSequence , asList ) ;
if ( removePrefix = = null ) {
return Collections . emptyList ( ) ;
}
List < String > baseNames = toBaseNames ( removePrefix , z2 , fluent ) ;
HashSet hashSet = new HashSet ( ) ;
Iterator < String > it = baseNames . iterator ( ) ;
while ( it . hasNext ( ) ) {
String next = it . next ( ) ;
if ( ! z3 | | ! fluent ) {
hashSet . add ( buildAccessorName ( str2 , next ) ) ;
if ( ! str2 . equals ( str ) ) {
hashSet . add ( buildAccessorName ( str , next ) ) ;
}
} else {
hashSet . add ( next ) ;
}
}
return new ArrayList ( hashSet ) ;
}
private static List < String > toBaseNames ( CharSequence charSequence , boolean z2 , boolean z3 ) {
ArrayList arrayList = new ArrayList ( ) ;
arrayList . add ( charSequence . toString ( ) ) ;
String charSequence2 = charSequence . toString ( ) ;
if ( charSequence2 . startsWith ( " is " ) & & charSequence2 . length ( ) > 2 & & ! Character . isLowerCase ( charSequence2 . charAt ( 2 ) ) ) {
String substring = charSequence2 . substring ( 2 ) ;
if ( z3 ) {
arrayList . add ( Character . toLowerCase ( substring . charAt ( 0 ) ) + substring . substring ( 1 ) ) ;
} else {
arrayList . add ( substring ) ;
}
}
return arrayList ;
}
public static String buildAccessorName ( String str , String str2 ) {
if ( str2 . length ( ) = = 0 ) {
return str ;
}
if ( str . length ( ) = = 0 ) {
return str2 ;
}
char charAt = str2 . charAt ( 0 ) ;
if ( Character . isLowerCase ( charAt ) ) {
Object [ ] objArr = new Object [ 2 ] ;
objArr [ 0 ] = Character . valueOf ( str2 . length ( ) > 2 & & ( Character . isTitleCase ( str2 . charAt ( 1 ) ) | | Character . isUpperCase ( str2 . charAt ( 1 ) ) ) ? Character . toUpperCase ( charAt ) : Character . toTitleCase ( charAt ) ) ;
objArr [ 1 ] = str2 . subSequence ( 1 , str2 . length ( ) ) ;
str2 = String . format ( " %s%s " , objArr ) ;
}
return String . format ( " %s%s " , str , str2 ) ;
}
public static String camelCaseToConstant ( String str ) {
if ( str = = null | | str . isEmpty ( ) ) {
return " " ;
}
StringBuilder sb = new StringBuilder ( ) ;
sb . append ( Character . toUpperCase ( str . charAt ( 0 ) ) ) ;
for ( int i = 1 ; i < str . length ( ) ; i + + ) {
char charAt = str . charAt ( i ) ;
if ( Character . isUpperCase ( charAt ) ) {
sb . append ( '_' ) ;
}
sb . append ( Character . toUpperCase ( charAt ) ) ;
}
return sb . toString ( ) ;
}
public static int defaultEqualsAndHashcodeIncludeRank ( String str ) {
if ( JavaIdentifiers . isPrimitive ( str ) ) {
return 1000 ;
}
return PRIMITIVE_WRAPPER_TYPE_NAME_PATTERN . matcher ( str ) . matches ( ) ? 800 : 0 ;
}
public static String stripLinesWithTagFromJavadoc ( String str , String str2 ) {
return Pattern . compile ( " ^ \\ s* \\ ** \\ s* " + str2 + " \\ s* \\ ** \\ s*$ " , 10 ) . matcher ( str ) . replaceAll ( " " ) ;
}
public static String stripSectionsFromJavadoc ( String str ) {
Matcher matcher = SECTION_FINDER . matcher ( str ) ;
return ! matcher . find ( ) ? str : str . substring ( 0 , matcher . start ( ) ) ;
}
public static String getJavadocSection ( String str , String str2 ) {
String [ ] split = str2 . split ( " \\ | " ) ;
Matcher matcher = SECTION_FINDER . matcher ( str ) ;
Matcher matcher2 = LINE_BREAK_FINDER . matcher ( str ) ;
int i = - 1 ;
int i2 = - 1 ;
while ( matcher . find ( ) ) {
boolean z2 = false ;
int length = split . length ;
int i3 = 0 ;
while ( true ) {
if ( i3 > = length ) {
break ;
}
if ( matcher . group ( 1 ) . equalsIgnoreCase ( split [ i3 ] ) ) {
z2 = true ;
break ;
}
i3 + + ;
}
if ( z2 ) {
matcher2 . find ( matcher . end ( ) ) ;
i = matcher2 . end ( ) ;
} else if ( i ! = - 1 ) {
i2 = matcher . start ( ) ;
}
}
if ( i ! = - 1 ) {
return i2 ! = - 1 ? str . substring ( i , i2 ) : str . substring ( i ) ;
}
return null ;
}
public static String addReturnsThisIfNeeded ( String str ) {
return FIND_RETURN . matcher ( str ) . find ( ) ? str : addJavadocLine ( str , " @return {@code this}. " ) ;
}
public static String addReturnsUpdatedSelfIfNeeded ( String str ) {
return FIND_RETURN . matcher ( str ) . find ( ) ? str : addJavadocLine ( str , " @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed). " ) ;
}
public static String addJavadocLine ( String str , String str2 ) {
return str . endsWith ( " \ n " ) ? String . valueOf ( str ) + str2 + " \ n " : String . valueOf ( str ) + " \ n " + str2 ;
}
}