2022-03-01 22:12:19 +00:00
package lombok.core.configuration ;
import java.util.ArrayList ;
import java.util.Iterator ;
import java.util.List ;
import java.util.regex.Matcher ;
import java.util.regex.Pattern ;
2022-03-09 08:59:06 +00:00
/* loaded from: com.discord-118107.apk:lombok/core/configuration/LogDeclaration.SCL.lombok */
2022-03-01 22:12:19 +00:00
public final class LogDeclaration implements ConfigurationValueType {
private static final Pattern PARAMETERS_PATTERN = Pattern . compile ( " (?: \\ (([A-Z,]*) \\ )) " ) ;
private static final Pattern DECLARATION_PATTERN = Pattern . compile ( " ^(?:([^ ]+) )?([^(]+) \\ .([^(]+)( " + PARAMETERS_PATTERN . pattern ( ) + " +)$ " ) ;
private final TypeName loggerType ;
private final TypeName loggerFactoryType ;
private final IdentifierName loggerFactoryMethod ;
private final List < LogFactoryParameter > parametersWithoutTopic ;
private final List < LogFactoryParameter > parametersWithTopic ;
2022-03-09 08:59:06 +00:00
/* loaded from: com.discord-118107.apk:lombok/core/configuration/LogDeclaration$LogFactoryParameter.SCL.lombok */
2022-03-01 22:12:19 +00:00
public enum LogFactoryParameter {
TYPE ,
NAME ,
TOPIC ,
NULL
}
private LogDeclaration ( TypeName typeName , TypeName typeName2 , IdentifierName identifierName , List < LogFactoryParameter > list , List < LogFactoryParameter > list2 ) {
this . loggerType = typeName ;
this . loggerFactoryType = typeName2 ;
this . loggerFactoryMethod = identifierName ;
this . parametersWithoutTopic = list ;
this . parametersWithTopic = list2 ;
}
public static LogDeclaration valueOf ( String str ) {
if ( str = = null ) {
return null ;
}
Matcher matcher = DECLARATION_PATTERN . matcher ( str ) ;
if ( ! matcher . matches ( ) ) {
throw new IllegalArgumentException ( " The declaration must follow the pattern: [LoggerType ]LoggerFactoryType.loggerFactoryMethod(loggerFactoryMethodParams)[(loggerFactoryMethodParams)] " ) ;
}
TypeName valueOf = TypeName . valueOf ( matcher . group ( 2 ) ) ;
TypeName valueOf2 = TypeName . valueOf ( matcher . group ( 1 ) ) ;
if ( valueOf2 = = null ) {
valueOf2 = valueOf ;
}
IdentifierName valueOf3 = IdentifierName . valueOf ( matcher . group ( 3 ) ) ;
List < LogFactoryParameter > list = null ;
List < LogFactoryParameter > list2 = null ;
Iterator < List < LogFactoryParameter > > it = parseParameters ( matcher . group ( 4 ) ) . iterator ( ) ;
while ( it . hasNext ( ) ) {
List < LogFactoryParameter > next = it . next ( ) ;
if ( next . contains ( LogFactoryParameter . TOPIC ) ) {
if ( list2 ! = null ) {
throw new IllegalArgumentException ( " There is more than one parameter definition that includes TOPIC: " + list2 + " and " + next ) ;
}
list2 = next ;
} else if ( list ! = null ) {
throw new IllegalArgumentException ( " There is more than one parmaeter definition that does not include TOPIC: " + list + " and " + next ) ;
} else {
list = next ;
}
}
if ( list ! = null | | list2 ! = null ) {
return new LogDeclaration ( valueOf2 , valueOf , valueOf3 , list , list2 ) ;
}
throw new IllegalArgumentException ( " No logger factory method parameters specified. " ) ;
}
private static List < List < LogFactoryParameter > > parseParameters ( String str ) {
ArrayList arrayList = new ArrayList ( ) ;
Matcher matcher = PARAMETERS_PATTERN . matcher ( str ) ;
while ( matcher . find ( ) ) {
String group = matcher . group ( 1 ) ;
ArrayList arrayList2 = new ArrayList ( ) ;
if ( ! group . isEmpty ( ) ) {
for ( String str2 : group . split ( " , " ) ) {
arrayList2 . add ( LogFactoryParameter . valueOf ( str2 ) ) ;
}
}
arrayList . add ( arrayList2 ) ;
}
return arrayList ;
}
public static String description ( ) {
return " custom-log-declaration " ;
}
public static String exampleValue ( ) {
return " my.cool.Logger my.cool.LoggerFactory.createLogger()(TOPIC,TYPE) " ;
}
public boolean equals ( Object obj ) {
if ( ! ( obj instanceof LogDeclaration ) ) {
return false ;
}
if ( ! this . loggerType . equals ( ( ( LogDeclaration ) obj ) . loggerType ) | | ! this . loggerFactoryType . equals ( ( ( LogDeclaration ) obj ) . loggerFactoryType ) | | ! this . loggerFactoryMethod . equals ( ( ( LogDeclaration ) obj ) . loggerFactoryMethod ) | | this . parametersWithoutTopic ! = ( ( LogDeclaration ) obj ) . parametersWithoutTopic ) {
return ( this . parametersWithoutTopic . equals ( ( ( LogDeclaration ) obj ) . parametersWithoutTopic ) & & this . parametersWithTopic = = ( ( LogDeclaration ) obj ) . parametersWithTopic ) | | this . parametersWithTopic . equals ( ( ( LogDeclaration ) obj ) . parametersWithTopic ) ;
}
return true ;
}
public int hashCode ( ) {
return ( 31 * ( ( 31 * ( ( 31 * ( ( 31 * ( ( 31 * 1 ) + this . loggerType . hashCode ( ) ) ) + this . loggerFactoryType . hashCode ( ) ) ) + this . loggerFactoryMethod . hashCode ( ) ) ) + ( this . parametersWithTopic = = null ? 0 : this . parametersWithTopic . hashCode ( ) ) ) ) + ( this . parametersWithoutTopic = = null ? 0 : this . parametersWithoutTopic . hashCode ( ) ) ;
}
public String toString ( ) {
StringBuilder sb = new StringBuilder ( ) ;
sb . append ( this . loggerType ) ;
sb . append ( " " ) ;
sb . append ( this . loggerFactoryType ) ;
sb . append ( " . " ) ;
sb . append ( this . loggerFactoryMethod ) ;
appendParams ( sb , this . parametersWithoutTopic ) ;
appendParams ( sb , this . parametersWithTopic ) ;
return sb . toString ( ) ;
}
private static void appendParams ( StringBuilder sb , List < LogFactoryParameter > list ) {
if ( list ! = null ) {
sb . append ( " ( " ) ;
boolean z2 = true ;
Iterator < LogFactoryParameter > it = list . iterator ( ) ;
while ( it . hasNext ( ) ) {
LogFactoryParameter next = it . next ( ) ;
if ( ! z2 ) {
sb . append ( " , " ) ;
}
z2 = false ;
sb . append ( next ) ;
}
sb . append ( " ) " ) ;
}
}
public TypeName getLoggerType ( ) {
return this . loggerType ;
}
public TypeName getLoggerFactoryType ( ) {
return this . loggerFactoryType ;
}
public IdentifierName getLoggerFactoryMethod ( ) {
return this . loggerFactoryMethod ;
}
public List < LogFactoryParameter > getParametersWithoutTopic ( ) {
return this . parametersWithoutTopic ;
}
public List < LogFactoryParameter > getParametersWithTopic ( ) {
return this . parametersWithTopic ;
}
}