idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
23,700 | public static RecordingTransaction wrap ( Transaction tx , Predicate < LogEntry > filter ) { return new RecordingTransaction ( tx , filter ) ; } | Creates a RecordingTransaction using the provided LogEntry filter and existing Transaction |
23,701 | protected InputContainerElements scan ( final UIComponent component , InputContainerElements elements , final FacesContext context ) { if ( elements == null ) { elements = new InputContainerElements ( ) ; } if ( ( elements . getLabel ( ) == null ) && ( component instanceof HtmlOutputLabel ) ) { elements . setLabel ( ( HtmlOutputLabel ) component ) ; } else if ( component instanceof EditableValueHolder ) { elements . registerInput ( ( EditableValueHolder ) component , getDefaultValidator ( context ) , context ) ; } else if ( component instanceof UIMessage ) { elements . registerMessage ( ( UIMessage ) component ) ; } for ( UIComponent child : component . getChildren ( ) ) { scan ( child , elements , context ) ; } return elements ; } | Walk the component tree branch built by the composite component and locate the input container elements . |
23,702 | public void assignIds ( final InputContainerElements elements , final FacesContext context ) { boolean refreshIds = false ; if ( getId ( ) . startsWith ( UIViewRoot . UNIQUE_ID_PREFIX ) ) { setId ( elements . getPropertyName ( context ) ) ; refreshIds = true ; } UIComponent label = elements . getLabel ( ) ; if ( label != null ) { if ( label . getId ( ) . startsWith ( UIViewRoot . UNIQUE_ID_PREFIX ) ) { label . setId ( getDefaultLabelId ( ) ) ; } else if ( refreshIds ) { label . setId ( label . getId ( ) ) ; } } for ( int i = 0 , len = elements . getInputs ( ) . size ( ) ; i < len ; i ++ ) { UIComponent input = ( UIComponent ) elements . getInputs ( ) . get ( i ) ; if ( input . getId ( ) . startsWith ( UIViewRoot . UNIQUE_ID_PREFIX ) ) { input . setId ( getDefaultInputId ( ) + ( i == 0 ? "" : ( i + 1 ) ) ) ; } else if ( refreshIds ) { input . setId ( input . getId ( ) ) ; } } for ( int i = 0 , len = elements . getMessages ( ) . size ( ) ; i < len ; i ++ ) { UIComponent msg = elements . getMessages ( ) . get ( i ) ; if ( msg . getId ( ) . startsWith ( UIViewRoot . UNIQUE_ID_PREFIX ) ) { msg . setId ( getDefaultMessageId ( ) + ( i == 0 ? "" : ( i + 1 ) ) ) ; } else if ( refreshIds ) { msg . setId ( msg . getId ( ) ) ; } } } | assigning ids seems to break form submissions but I don t know why |
23,703 | private Validator getDefaultValidator ( final FacesContext context ) throws FacesException { if ( ! beanValidationPresent ) { return null ; } ValidatorFactory validatorFactory ; Object cachedObject = context . getExternalContext ( ) . getApplicationMap ( ) . get ( BeanValidator . VALIDATOR_FACTORY_KEY ) ; if ( cachedObject instanceof ValidatorFactory ) { validatorFactory = ( ValidatorFactory ) cachedObject ; } else { try { validatorFactory = Validation . buildDefaultValidatorFactory ( ) ; } catch ( ValidationException e ) { throw new FacesException ( "Could not build a default Bean Validator factory" , e ) ; } context . getExternalContext ( ) . getApplicationMap ( ) . put ( BeanValidator . VALIDATOR_FACTORY_KEY , validatorFactory ) ; } return validatorFactory . getValidator ( ) ; } | Get the default Bean Validation Validator to read the contraints for a property . |
23,704 | public SetType getBlockedThreads ( ) { Set < ThreadType > blocked = new LinkedHashSet < ThreadType > ( ) ; for ( ThreadType thread : runtime . getThreads ( ) ) { if ( thread == this ) continue ; if ( getAcquiredLocks ( ) . contains ( thread . getWaitingToLock ( ) ) ) { blocked . add ( thread ) ; } } return runtime . getThreadSet ( blocked ) ; } | Get threads that are waiting for lock held by this thread . |
23,705 | public SetType getBlockingThreads ( ) { final ThreadType blocking = getBlockingThread ( ) ; if ( blocking == null ) return runtime . getEmptyThreadSet ( ) ; return runtime . getThreadSet ( Collections . singleton ( blocking ) ) ; } | Get threads holding lock this thread is trying to acquire . |
23,706 | public ThreadType getBlockingThread ( ) { if ( state . waitingToLock == null && state . waitingOnLock == null ) { return null ; } for ( ThreadType thread : runtime . getThreads ( ) ) { if ( thread == this ) continue ; Set < ThreadLock > acquired = thread . getAcquiredLocks ( ) ; if ( acquired . isEmpty ( ) ) continue ; if ( acquired . contains ( state . waitingToLock ) || acquired . contains ( state . waitingOnLock ) ) { return thread ; } } return null ; } | Get thread blocking this threads execution . |
23,707 | private void init ( String xmlPath ) throws MalformedURLException , IOException { XML xml = new XML ( true , xmlPath ) ; if ( ! xml . isInheritedMapped ( configuredClass ) ) Error . classNotMapped ( configuredClass ) ; for ( Class < ? > classe : getClasses ( xml ) ) { relationalManyToOneMapper . put ( classe . getName ( ) , new JMapper ( configuredClass , classe , ChooseConfig . DESTINATION , xmlPath ) ) ; relationalOneToManyMapper . put ( classe . getName ( ) , new JMapper ( classe , configuredClass , ChooseConfig . SOURCE , xmlPath ) ) ; } } | This method initializes relational maps starting from XML . |
23,708 | private Set < Class < ? > > getClasses ( XML xml ) { HashSet < Class < ? > > result = new HashSet < Class < ? > > ( ) ; Global global = null ; for ( Class < ? > clazz : getAllsuperClasses ( configuredClass ) ) { if ( isNull ( global ) ) { global = xml . loadGlobals ( ) . get ( clazz . getName ( ) ) ; if ( ! isNull ( global ) ) { addClasses ( global . getClasses ( ) , result ) ; if ( global . getExcluded ( ) != null ) for ( Attribute attribute : xml . loadAttributes ( ) . get ( clazz . getName ( ) ) ) for ( String fieldName : global . getExcluded ( ) ) if ( attribute . getName ( ) . equals ( fieldName ) ) addClasses ( attribute . getClasses ( ) , result , attribute . getName ( ) ) ; } } List < Attribute > attributes = xml . loadAttributes ( ) . get ( clazz . getName ( ) ) ; if ( ! isNull ( attributes ) ) for ( Attribute attribute : attributes ) if ( isNull ( global ) || isPresent ( global . getExcluded ( ) , attribute . getName ( ) ) || ( ! isEmpty ( global . getAttributes ( ) ) && ! isPresent ( global . getAttributes ( ) , new SimplyAttribute ( attribute . getName ( ) ) ) ) ) addClasses ( attribute . getClasses ( ) , result , attribute . getName ( ) ) ; } return result ; } | Returns all Target Classes contained in the XML . |
23,709 | private void init ( ) { if ( ! Annotation . isInheritedMapped ( configuredClass ) ) Error . classNotMapped ( configuredClass ) ; for ( Class < ? > classe : getClasses ( ) ) { relationalManyToOneMapper . put ( classe . getName ( ) , new JMapper ( configuredClass , classe , ChooseConfig . DESTINATION ) ) ; relationalOneToManyMapper . put ( classe . getName ( ) , new JMapper ( classe , configuredClass , ChooseConfig . SOURCE ) ) ; } } | This method initializes relational maps |
23,710 | private Set < Class < ? > > getClasses ( ) { HashSet < Class < ? > > result = new HashSet < Class < ? > > ( ) ; JGlobalMap jGlobalMap = null ; for ( Class < ? > clazz : getAllsuperClasses ( configuredClass ) ) { if ( isNull ( jGlobalMap ) ) { jGlobalMap = clazz . getAnnotation ( JGlobalMap . class ) ; if ( ! isNull ( jGlobalMap ) ) { addClasses ( jGlobalMap . classes ( ) , result ) ; if ( ! isNull ( jGlobalMap . excluded ( ) ) ) for ( Field field : getListOfFields ( configuredClass ) ) { JMap jMap = field . getAnnotation ( JMap . class ) ; if ( ! isNull ( jMap ) ) for ( String fieldName : jGlobalMap . excluded ( ) ) if ( field . getName ( ) . equals ( fieldName ) ) addClasses ( jMap . classes ( ) , result , field . getName ( ) ) ; } return result ; } } } for ( Field field : getListOfFields ( configuredClass ) ) { JMap jMap = field . getAnnotation ( JMap . class ) ; if ( ! isNull ( jMap ) ) addClasses ( jMap . classes ( ) , result , field . getName ( ) ) ; } return result ; } | Returns all Target Classes |
23,711 | private < I > I destinationClassControl ( Exception exception , Class < I > clazz ) { try { if ( clazz == null ) throw new IllegalArgumentException ( "it's mandatory define the destination class" ) ; } catch ( Exception e ) { JmapperLog . error ( e ) ; return null ; } return logAndReturnNull ( exception ) ; } | This method verifies that the destinationClass exists . |
23,712 | private < D , S > JMapper < D , S > getJMapper ( HashMap < String , JMapper > map , Object source ) { Class < ? > sourceClass = source instanceof Class ? ( ( Class < ? > ) source ) : source . getClass ( ) ; JMapper < D , S > jMapper = map . get ( sourceClass . getName ( ) ) ; if ( jMapper == null ) Error . classNotMapped ( source , configuredClass ) ; return jMapper ; } | Returns the desired JMapper instance . |
23,713 | public Global excludedAttributes ( String ... attributes ) { for ( String attribute : attributes ) global . excluded . add ( new XmlExcludedAttribute ( attribute ) ) ; return this ; } | Attributes to exclude from mapping . |
23,714 | public Global targetClasses ( Class < ? > ... classes ) { for ( Class < ? > targetClass : classes ) global . classes . add ( new TargetClass ( targetClass ) . toXStream ( ) ) ; return this ; } | Target classes . |
23,715 | public boolean isUndefined ( final Field destination , final Field source ) { info = null ; for ( IOperationAnalyzer analyzer : analyzers ) if ( analyzer . verifyConditions ( destination , source ) ) info = analyzer . getInfoOperation ( destination , source ) ; if ( isNull ( info ) ) info = undefinedOperation ( ) ; boolean conversionMethodExists = conversionAnalyzer . fieldsToCheck ( destination , source ) ; OperationType operationType = info . getOperationType ( ) ; if ( operationType . isUndefined ( ) && ! conversionMethodExists ) return true ; if ( conversionMethodExists ) info . setInstructionType ( operationType . isBasic ( ) ? OperationType . BASIC_CONVERSION : OperationType . CONVERSION ) ; return false ; } | This method analyzes the fields calculates the info and returns true if operation is undefined . |
23,716 | private String getValue ( final String value , final String mappedFieldName ) { if ( isNull ( value ) ) return null ; return value . equals ( DEFAULT_FIELD_VALUE ) ? mappedFieldName : value ; } | This method compare the name of the target field with the DEFAULT_FIELD_VALUE and returns the final value . |
23,717 | private String getValue ( final List < String > attributes , final List < Class < ? > > classes , String value , final String mappedFieldName , final Class < ? > configuredClass , final Class < ? > targetClass ) { String regex = getValue ( value , mappedFieldName ) ; String mappedClassName = configuredClass . getSimpleName ( ) ; String targetClassName = targetClass . getSimpleName ( ) ; if ( attributes . isEmpty ( ) && classes . isEmpty ( ) ) { String targetFieldName = fieldName ( targetClass , regex ) ; if ( ! isNull ( targetFieldName ) ) return targetFieldName ; Error . mapping ( mappedFieldName , mappedClassName , regex , targetClassName ) ; } if ( attributes . isEmpty ( ) && ! classes . isEmpty ( ) ) { if ( classes . contains ( targetClass ) ) { String targetFieldName = fieldName ( targetClass , regex ) ; if ( ! isNull ( targetFieldName ) ) return targetFieldName ; } Error . mapping ( mappedFieldName , mappedClassName , regex , targetClassName ) ; } if ( ! attributes . isEmpty ( ) && ! classes . isEmpty ( ) ) if ( attributes . size ( ) == classes . size ( ) ) if ( classes . contains ( targetClass ) ) { String targetClassValue = attributes . get ( classes . indexOf ( targetClass ) ) ; regex = getValue ( targetClassValue , mappedFieldName ) ; String targetFieldName = fieldName ( targetClass , regex ) ; if ( ! isNull ( targetFieldName ) ) return targetFieldName ; Error . mapping ( mappedFieldName , mappedClassName , regex , targetClassName ) ; } else Error . mapping ( mappedFieldName , mappedClassName , targetClassName ) ; else Error . mapping ( mappedFieldName , mappedClassName ) ; if ( ! attributes . isEmpty ( ) && classes . isEmpty ( ) ) for ( String str : attributes ) { regex = getValue ( str , mappedFieldName ) ; String targetFieldName = fieldName ( targetClass , regex ) ; if ( ! isNull ( targetFieldName ) ) return targetFieldName ; } Error . mapping ( mappedFieldName , configuredClass , targetClass ) ; return "this return is never used" ; } | This method finds the target field name from mapped parameters . |
23,718 | public void loadAccessors ( Class < ? > targetClass , MappedField configuredField , MappedField targetField ) { xml . fillMappedField ( configuredClass , configuredField ) . fillMappedField ( targetClass , targetField ) . fillOppositeField ( configuredClass , configuredField , targetField ) ; Annotation . fillMappedField ( configuredClass , configuredField ) ; Annotation . fillMappedField ( targetClass , targetField ) ; Annotation . fillOppositeField ( configuredClass , configuredField , targetField ) ; } | Fill fields with they custom methods . |
23,719 | public List < ConversionMethod > getConversionMethods ( Class < ? > clazz ) { List < ConversionMethod > conversions = new ArrayList < ConversionMethod > ( ) ; Map < String , List < ConversionMethod > > conversionsMap = this . conversionsLoad ( ) ; for ( Class < ? > classToCheck : getAllsuperClasses ( clazz ) ) { List < ConversionMethod > methods = conversionsMap . get ( classToCheck . getName ( ) ) ; if ( methods != null ) conversions . addAll ( methods ) ; } return conversions ; } | Returns the conversions method belonging to clazz . |
23,720 | public List < String > getClasses ( ) { List < String > classes = new ArrayList < String > ( ) ; for ( XmlClass xmlClass : xmlJmapper . classes ) classes . add ( xmlClass . name ) ; return classes ; } | Returns a list with the classes names presents in xml mapping file . |
23,721 | public XML write ( ) { try { FilesManager . write ( xmlJmapper , xmlPath ) ; } catch ( IOException e ) { JmapperLog . error ( e ) ; } return this ; } | Writes the xml mapping file starting from xmlJmapper object . |
23,722 | public XML deleteClass ( Class < ? > aClass ) { boolean isRemoved = xmlJmapper . classes . remove ( new XmlClass ( aClass . getName ( ) ) ) ; if ( ! isRemoved ) Error . xmlClassInexistent ( this . xmlPath , aClass ) ; return this ; } | This method remove a specific Class from Xml Configuration File |
23,723 | public XML addGlobal ( Class < ? > aClass , Global global ) { checksGlobalAbsence ( aClass ) ; findXmlClass ( aClass ) . global = Converter . toXmlGlobal ( global ) ; return this ; } | This method adds the global to an existing Class . |
23,724 | public XML deleteGlobal ( Class < ? > aClass ) { checksGlobalExistence ( aClass ) ; XmlClass xmlClass = findXmlClass ( aClass ) ; if ( isEmpty ( xmlClass . attributes ) ) deleteClass ( aClass ) ; else xmlClass . global = null ; return this ; } | This method deletes the global to an existing Class . |
23,725 | public XML addAttributes ( Class < ? > aClass , Attribute [ ] attributes ) { checksAttributesExistence ( aClass , attributes ) ; for ( Attribute attribute : attributes ) { if ( attributeExists ( aClass , attribute ) ) Error . xmlAttributeExistent ( this . xmlPath , attribute , aClass ) ; findXmlClass ( aClass ) . attributes . add ( Converter . toXmlAttribute ( attribute ) ) ; } return this ; } | This method adds the attributes to an existing Class . |
23,726 | public XML deleteAttributes ( Class < ? > aClass , String [ ] attributes ) { checksAttributesExistence ( aClass , attributes ) ; if ( isEmpty ( findXmlClass ( aClass ) . attributes ) || findXmlClass ( aClass ) . attributes . size ( ) <= 1 ) Error . xmlWrongMethod ( aClass ) ; for ( String attributeName : attributes ) { XmlAttribute attribute = null ; for ( XmlAttribute xmlAttribute : findXmlClass ( aClass ) . attributes ) if ( xmlAttribute . name . equals ( attributeName ) ) attribute = xmlAttribute ; if ( attribute == null ) Error . xmlAttributeInexistent ( this . xmlPath , attributeName , aClass ) ; findXmlClass ( aClass ) . attributes . remove ( attribute ) ; } return this ; } | This method deletes the attributes to an existing Class . |
23,727 | private XML addClass ( Class < ? > aClass ) { xmlJmapper . classes . add ( Converter . toXmlClass ( aClass ) ) ; return this ; } | Adds an annotated Class to xmlJmapper structure . |
23,728 | private XML checksClassAbsence ( Class < ? > aClass ) { if ( classExists ( aClass ) ) Error . xmlClassExistent ( this . xmlPath , aClass ) ; return this ; } | Throws an exception if the class exist . |
23,729 | private boolean classExists ( Class < ? > aClass ) { if ( xmlJmapper . classes == null ) return false ; return findXmlClass ( aClass ) != null ? true : false ; } | verifies that this class exist in Xml Configuration File . |
23,730 | private boolean attributeExists ( Class < ? > aClass , Attribute attribute ) { if ( ! classExists ( aClass ) ) return false ; for ( XmlAttribute xmlAttribute : findXmlClass ( aClass ) . attributes ) if ( xmlAttribute . name . equals ( attribute . getName ( ) ) ) return true ; return false ; } | This method returns true if the attribute exist in the Class given in input returns false otherwise . |
23,731 | private XmlClass findXmlClass ( Class < ? > aClass ) { for ( XmlClass xmlClass : xmlJmapper . classes ) if ( xmlClass . name . equals ( aClass . getName ( ) ) ) return xmlClass ; return null ; } | Finds the Class given in input in the xml mapping file and returns a XmlClass instance if exist null otherwise . |
23,732 | public boolean isMapped ( Class < ? > classToCheck ) { return ! isNull ( loadGlobals ( ) . get ( classToCheck . getName ( ) ) ) || ! isEmpty ( loadAttributes ( ) . get ( classToCheck . getName ( ) ) ) ; } | Returns true if the class is configured in xml false otherwise . |
23,733 | public XML fillMappedField ( Class < ? > configuredClass , MappedField configuredField ) { Attribute attribute = getGlobalAttribute ( configuredField , configuredClass ) ; if ( isNull ( attribute ) ) attribute = getAttribute ( configuredField , configuredClass ) ; if ( ! isNull ( attribute ) ) { if ( isEmpty ( configuredField . getMethod ( ) ) ) configuredField . getMethod ( attribute . getGet ( ) ) ; if ( isEmpty ( configuredField . setMethod ( ) ) ) configuredField . setMethod ( attribute . getSet ( ) ) ; } return this ; } | Enrich configuredField with get and set define in xml configuration . |
23,734 | public XML fillOppositeField ( Class < ? > configuredClass , MappedField configuredField , MappedField targetField ) { Attribute attribute = null ; Global global = loadGlobals ( ) . get ( configuredClass . getName ( ) ) ; if ( ! isNull ( global ) ) { String value = global . getValue ( ) ; if ( ! isEmpty ( value ) && value . equals ( targetField . getValue ( ) . getName ( ) ) ) { String get = global . getGet ( ) ; String set = global . getSet ( ) ; if ( ! isNull ( get ) || ! isNull ( set ) ) attribute = new Attribute ( null , new Value ( global . getValue ( ) , get , set ) ) ; } } if ( isNull ( attribute ) ) attribute = getAttribute ( configuredField , configuredClass ) ; if ( ! isNull ( attribute ) ) { Value value = attribute . getValue ( ) ; if ( ! isNull ( value ) ) if ( targetField . getValue ( ) . getName ( ) . equals ( value . getName ( ) ) ) { if ( isEmpty ( targetField . getMethod ( ) ) ) targetField . getMethod ( value . getGet ( ) ) ; if ( isEmpty ( targetField . setMethod ( ) ) ) targetField . setMethod ( value . getSet ( ) ) ; } SimplyAttribute [ ] attributes = attribute . getAttributes ( ) ; if ( ! isNull ( attributes ) ) for ( SimplyAttribute targetAttribute : attributes ) if ( targetField . getValue ( ) . getName ( ) . equals ( targetAttribute . getName ( ) ) ) { if ( isEmpty ( targetField . getMethod ( ) ) ) targetField . getMethod ( targetAttribute . getGet ( ) ) ; if ( isEmpty ( targetField . setMethod ( ) ) ) targetField . setMethod ( targetAttribute . getSet ( ) ) ; } } return this ; } | Enrich targetField with get and set define in xml configuration . |
23,735 | public static boolean safeNavigationOperatorDefined ( String nestedFieldName ) { if ( nestedFieldName . contains ( SAFE_NAVIGATION_OPERATOR ) ) if ( ! nestedFieldName . startsWith ( SAFE_NAVIGATION_OPERATOR ) ) throw new MappingException ( "Safe navigation operator must be the first symbol after dot notation" ) ; else return true ; return false ; } | It checks the presence of the elvis operator and how it is used . |
23,736 | private static MappedField checkGetAccessor ( XML xml , Class < ? > aClass , Field nestedField ) { MappedField field = new MappedField ( nestedField ) ; xml . fillMappedField ( aClass , field ) ; Annotation . fillMappedField ( aClass , field ) ; verifyGetterMethods ( aClass , field ) ; return field ; } | Checks only get accessor of this field . |
23,737 | private static MappedField checkAccessors ( XML xml , Class < ? > aClass , Field nestedField ) { MappedField field = checkGetAccessor ( xml , aClass , nestedField ) ; verifySetterMethods ( aClass , field ) ; return field ; } | Checks get and set accessors of this field . |
23,738 | public static NestedMappingInfo loadNestedMappingInformation ( XML xml , Class < ? > targetClass , String nestedMappingPath , Class < ? > sourceClass , Class < ? > destinationClass , Field configuredField ) { boolean isSourceClass = targetClass == sourceClass ; NestedMappingInfo info = new NestedMappingInfo ( isSourceClass ) ; info . setConfiguredClass ( isSourceClass ? destinationClass : sourceClass ) ; info . setConfiguredField ( configuredField ) ; try { Class < ? > nestedClass = targetClass ; String [ ] nestedFields = nestedFields ( nestedMappingPath ) ; Field field = null ; for ( int i = 0 ; i < nestedFields . length ; i ++ ) { String nestedFieldName = nestedFields [ i ] ; boolean elvisOperatorDefined = false ; if ( i < nestedFields . length - 1 ) { String nextNestedFieldName = nestedFields [ i + 1 ] ; elvisOperatorDefined = safeNavigationOperatorDefined ( nextNestedFieldName ) ; } nestedFieldName = safeNavigationOperatorFilter ( nestedFieldName ) ; field = retrieveField ( nestedClass , nestedFieldName ) ; if ( isNull ( field ) ) Error . inexistentField ( nestedFieldName , nestedClass . getSimpleName ( ) ) ; MappedField nestedField = isSourceClass ? checkGetAccessor ( xml , nestedClass , field ) : checkAccessors ( xml , nestedClass , field ) ; info . addNestedField ( new NestedMappedField ( nestedField , nestedClass , elvisOperatorDefined ) ) ; nestedClass = field . getType ( ) ; } } catch ( MappingException e ) { InvalidNestedMappingException exception = new InvalidNestedMappingException ( nestedMappingPath ) ; exception . getMessages ( ) . put ( InvalidNestedMappingException . FIELD , e . getMessage ( ) ) ; throw exception ; } return info ; } | This method returns a bean with nested mapping information . |
23,739 | public static AGeneralOperation getOperation ( OperationType operationType ) { switch ( operationType ) { case BASIC_INSTRUCTION : return new BasicOperation ( ) ; case BASIC_CONVERSION : return new BasicConversion ( ) ; case OBJECT : return new ObjectOperation ( ) ; case ARRAY : return new ArrayOperation ( ) ; case ARRAY_LIST : return new ArrayListOperation ( ) ; case LIST_ARRAY : return new ListArrayOperation ( ) ; case ARRAY_WITH_MAPPED_ITEMS : return new MappedArrayOperation ( ) ; case ARRAY_LIST_WITH_MAPPED_ITEMS : return new MappedArrayListOperation ( ) ; case LIST_ARRAY_WITH_MAPPED_ITEMS : return new MappedListArrayOperation ( ) ; case COLLECTION : return new CollectionOperation ( ) ; case COLLECTION_WITH_MAPPED_ITEMS : return new MappedCollectionOperation ( ) ; case MAP : return new MapOperation ( ) ; case MAP_WITH_MAPPED_ITEMS : return new MappedMapOperation ( ) ; case CONVERSION : return new ConversionOperation ( ) ; case DATE_CALENDAR : return new DateCalendarOperation ( ) ; case STRING_ENUM : return new StringEnumOperation ( ) ; case STRING_STRINGBUFFER : return new StringStringBufferOperation ( ) ; case STRING_STRINGBUILDER : return new StringStringBuilderOperation ( ) ; case CALENDAR_DATE : return new CalendarDateOperation ( ) ; case ENUM_STRING : return new EnumStringOperation ( ) ; case STRINGBUILDER_STRING : return new StringBuilderStringOperation ( ) ; case STRINGBUFFER_STRING : return new StringBufferStringOperation ( ) ; case ENUM_ENUM : return new EnumEnumOperation ( ) ; default : return null ; } } | Operation factory . |
23,740 | public static InputStream loadResource ( String resource ) throws MalformedURLException , IOException { String content = resource . trim ( ) ; if ( ! isPath ( content ) ) return new ByteArrayInputStream ( content . getBytes ( "UTF-8" ) ) ; URL url = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( content ) ; if ( isNull ( url ) ) { ClassLoader classLoader = ResourceLoader . class . getClassLoader ( ) ; if ( classLoader != null ) url = classLoader . getResource ( content ) ; } if ( isNull ( url ) ) url = ClassLoader . getSystemResource ( content ) ; if ( isNull ( url ) && content . contains ( ":" ) ) url = new URL ( content ) ; if ( isNull ( url ) ) Error . xmlNotFound ( content ) ; return url . openStream ( ) ; } | Returns an instance of inputStream if resource exists null otherwise . |
23,741 | public boolean fieldsToCheck ( Field destination , Field source ) { destinationName = destination . getName ( ) ; sourceName = source . getName ( ) ; if ( ! xml . conversionsLoad ( ) . isEmpty ( ) ) { configurationType = XML ; if ( config == DESTINATION ) { if ( existsXmlConversion ( destinationClass ) ) { membership = Membership . DESTINATION ; return true ; } if ( existsXmlConversion ( sourceClass ) ) { membership = Membership . SOURCE ; return true ; } } else { if ( existsXmlConversion ( sourceClass ) ) { membership = Membership . SOURCE ; return true ; } if ( existsXmlConversion ( destinationClass ) ) { membership = Membership . DESTINATION ; return true ; } } } configurationType = ANNOTATION ; if ( config == DESTINATION ) { if ( existsAnnotatedConversion ( destinationClass ) ) { membership = Membership . DESTINATION ; return true ; } if ( existsAnnotatedConversion ( sourceClass ) ) { membership = Membership . SOURCE ; return true ; } } else { if ( existsAnnotatedConversion ( sourceClass ) ) { membership = Membership . SOURCE ; return true ; } if ( existsAnnotatedConversion ( destinationClass ) ) { membership = Membership . DESTINATION ; return true ; } } return false ; } | Checks for the existence of a conversion method . |
23,742 | private boolean exists ( List < ConversionMethod > conversions ) { if ( conversions . isEmpty ( ) ) return false ; return ( method = verifyConversionExistence ( conversions ) ) != null ; } | Verifies the conversion method existence returns true if exists false otherwise . |
23,743 | private ConversionMethod verifyConversionExistence ( List < ConversionMethod > conversions ) { for ( ConversionMethod method : conversions ) if ( isPresentIn ( method . getFrom ( ) , sourceName ) && isPresentIn ( method . getTo ( ) , destinationName ) ) return method ; return null ; } | This method finds the conversion method between those loaded . |
23,744 | private boolean isPresentIn ( String [ ] values , String field ) { for ( String value : values ) if ( value . equalsIgnoreCase ( JMapConversion . ALL ) || value . equals ( field ) ) return true ; return false ; } | Returns true if the field name is contained in the values array false otherwise . |
23,745 | public static void nestedBeanNull ( String currentField , String destinationClass , String destinationField , String sourceClass , String sourceField , boolean safeNavigationOperator ) { throw new NestedBeanNullException ( MSG . INSTANCE . message ( nestedBeanNullException , currentField , destinationClass , destinationField , sourceClass , sourceField ) , safeNavigationOperator ) ; } | Thrown when the source field is null in a mapping of nested type . |
23,746 | public static void bodyContainsIllegalCode ( Method method , Exception additionalInformation ) { Class < ? > clazz = method . getClazz ( ) ; if ( isNull ( clazz ) ) clazz = JMapper . class ; String originalName = method . getOriginalName ( ) ; if ( isNull ( originalName ) ) originalName = method . getName ( ) ; String message = clazz != JMapper . class ? MSG . INSTANCE . message ( conversionBodyIllegalCode , clazz . getSimpleName ( ) , originalName , "" + additionalInformation . getMessage ( ) ) : MSG . INSTANCE . message ( conversionBodyIllegalCode2 , "" + additionalInformation . getMessage ( ) ) ; throw new ConversionBodyIllegalCodeException ( message ) ; } | Thrown when the code contained in the body method is illegal . |
23,747 | public static void incorrectMethodDefinition ( String methodName , String className ) { throw new DynamicConversionMethodException ( MSG . INSTANCE . message ( dynamicConversionMethodException , methodName , className ) ) ; } | Thrown when the method don t respects the convetions beloging to the dynamic conversion implementation . |
23,748 | public static void incorrectBodyDefinition ( String methodName , String className ) { throw new DynamicConversionBodyException ( MSG . INSTANCE . message ( dynamicConversionBodyException , methodName , className ) ) ; } | Thrown when the body method don t respects the convetions beloging to the dynamic conversion implementation . |
23,749 | public static void attributeInexistent ( String attributeName , Class < ? > aClass ) { throw new IllegalArgumentException ( MSG . INSTANCE . message ( malformedBeanException2 , attributeName , aClass . getSimpleName ( ) ) ) ; } | Thrown if attributes isn t present in the xml file . |
23,750 | public static void xmlWrongMethod ( Class < ? > aClass ) { throw new WrongMethodException ( MSG . INSTANCE . message ( wrongMethodException1 , aClass . getSimpleName ( ) ) ) ; } | Thrown when the class has only one attribute . |
23,751 | public static void xmlClassInexistent ( String path , Class < ? > aClass ) { throw new XmlMappingClassDoesNotExistException ( MSG . INSTANCE . message ( xmlMappingClassDoesNotExistException1 , path , aClass . getSimpleName ( ) ) ) ; } | Thrown if class isn t present in xml file . |
23,752 | public static void xmlClassExistent ( String path , Class < ? > aClass ) { throw new XmlMappingClassExistException ( MSG . INSTANCE . message ( xmlMappingClassExistException1 , aClass . getSimpleName ( ) , path ) ) ; } | Thrown if class is present in xml file . |
23,753 | public static void xmlConversionNameUndefined ( String xmlPath , String className ) { throw new XmlConversionNameException ( MSG . INSTANCE . message ( xmlConversionNameException , xmlPath , className ) ) ; } | Thrown when the conversion name is undefined . |
23,754 | public static void xmlConversionTypeIncorrect ( String conversionName , String xmlPath , String className , String type ) { throw new XmlConversionTypeException ( MSG . INSTANCE . message ( xmlConversionTypeException , conversionName , xmlPath , className , type ) ) ; } | Thrown if conversion type is wrong . |
23,755 | public static void improperUseOfTheParameter ( String conversionName , String xmlPath , String className ) { throw new XmlConversionParameterException ( MSG . INSTANCE . message ( xmlConversionParameterException , conversionName , xmlPath , className ) ) ; } | Thrown if the use of the parameters is incorrect . |
23,756 | public static void undefinedMapping ( Field destinationField , Class < ? > destinationClass , Field sourceField , Class < ? > sourceClass ) { throw new UndefinedMappingException ( MSG . INSTANCE . message ( undefinedMappingException , destinationField . getName ( ) , destinationClass . getSimpleName ( ) , sourceField . getName ( ) , sourceClass . getSimpleName ( ) ) ) ; } | Thrown when the instruction isn t defined . |
23,757 | public static void badConversion ( Field destinationField , Class < ? > destinationClass , Field sourceField , Class < ? > sourceClass , String plus ) { throw new UndefinedMappingException ( MSG . INSTANCE . message ( undefinedMappingException , destinationField . getName ( ) , destinationClass . getSimpleName ( ) , sourceField . getName ( ) , sourceClass . getSimpleName ( ) ) + ". More information: " + plus ) ; } | Thrown when conversions are badly written . |
23,758 | public static void mapping ( String mappedFieldName , Class < ? > mappedClass , Class < ? > targetClass ) { throw new MappingErrorException ( MSG . INSTANCE . message ( mappingErrorException2 , mappedFieldName , mappedClass . getSimpleName ( ) , targetClass . getSimpleName ( ) ) ) ; } | Thrown when there is an error in the configuration . |
23,759 | public static void mapping ( String mappedFieldName , String mappedClassName ) { throw new MappingErrorException ( MSG . INSTANCE . message ( mappingErrorException2length , mappedFieldName , mappedClassName ) ) ; } | Thrown when the length of classes and attribute parameter isn t the same . |
23,760 | public static void mapping ( String mappedFieldName , String mappedClassName , String targetClassName ) { throw new MappingErrorException ( MSG . INSTANCE . message ( mappingErrorException3 , mappedFieldName , mappedClassName , targetClassName ) ) ; } | Thrown when the target class doesn t exist in classes parameter . |
23,761 | public static void attributeAbsent ( Class < ? > aClass , Attribute aField ) { throw new XmlMappingAttributeDoesNotExistException ( MSG . INSTANCE . message ( xmlMappingAttributeDoesNotExistException2 , aField . getName ( ) , aClass . getSimpleName ( ) , "API" ) ) ; } | Thrown if the attribute doesn t exist in aClass . |
23,762 | public static void configNotPresent ( Class < ? > destination , Class < ? > source , XML xml ) { throw new MappingNotFoundException ( MSG . INSTANCE . message ( Constants . mappingNotFoundException2path , destination . getSimpleName ( ) , source . getSimpleName ( ) , xml . getXmlPath ( ) ) ) ; } | Thrown when the xml configuration doesn t contains the classes configuration . |
23,763 | public static void configNotPresent ( Class < ? > clazz , XML xml ) { throw new MappingNotFoundException ( MSG . INSTANCE . message ( Constants . mappingNotFoundException1path , clazz . getSimpleName ( ) , xml . getXmlPath ( ) ) ) ; } | Thrown when missing the configuration belonging to clazz . |
23,764 | public static void classesNotConfigured ( Class < ? > destination , Class < ? > source ) { throw new MappingNotFoundException ( MSG . INSTANCE . message ( Constants . mappingNotFoundException2 , destination . getSimpleName ( ) , source . getSimpleName ( ) ) ) ; } | Thrown when the xml configuration doesn t exist . |
23,765 | public static void classNotConfigured ( Class < ? > clazz ) { throw new MappingNotFoundException ( MSG . INSTANCE . message ( Constants . mappingNotFoundException1 , clazz . getSimpleName ( ) ) ) ; } | Thrown when the xml configuration of the clazz doesn t exist . |
23,766 | public static void globalClassesAbsent ( Class < ? > aClass ) { throw new MappingErrorException ( MSG . INSTANCE . message ( mappingErrorRelationalException3 , aClass . getSimpleName ( ) ) ) ; } | Thrown if the configured class hasn t classes parameter . |
23,767 | public static void classesAbsent ( String fieldName , Class < ? > aClass ) { throw new MappingErrorException ( MSG . INSTANCE . message ( mappingErrorRelationalException2 , fieldName , aClass . getSimpleName ( ) ) ) ; } | Thrown if the configured field hasn t classes parameter . |
23,768 | public static void classNotMapped ( Class < ? > aClass ) { throw new ClassNotMappedException ( MSG . INSTANCE . message ( classNotMappedException1 , aClass . getSimpleName ( ) ) ) ; } | Thrown if the class isn t mapped . |
23,769 | public static void classNotMapped ( Object sourceClass , Class < ? > configuredClass ) { String sourceName = sourceClass instanceof Class ? ( ( Class < ? > ) sourceClass ) . getSimpleName ( ) : sourceClass . getClass ( ) . getSimpleName ( ) ; throw new ClassNotMappedException ( MSG . INSTANCE . message ( classNotMappedException2 , sourceName , configuredClass . getSimpleName ( ) ) ) ; } | Thrown if the sourceClass isn t mapped in configuredClass . |
23,770 | public static void illegalCode ( Class < ? > destination , Class < ? > source , String path , Throwable e ) { String additionalInformation = e . getMessage ( ) . split ( "," ) [ 1 ] ; throw new IllegalCodeException ( MSG . INSTANCE . message ( illegalCodePath , destination . getSimpleName ( ) , source . getSimpleName ( ) , path , additionalInformation ) ) ; } | Thrown when there is an error in mapper generated class . |
23,771 | public static void absentRelationship ( Class < ? > configuredClass , Class < ? > targetClass ) { throw new AbsentRelationshipException ( MSG . INSTANCE . message ( noRelationshipException , configuredClass . getSimpleName ( ) , targetClass . getSimpleName ( ) ) ) ; } | Thrown when there isn t correspondence between classes . |
23,772 | public static void emptyConstructorAbsent ( Class < ? > aClass ) { throw new MalformedBeanException ( MSG . INSTANCE . message ( malformedBeanException1 , aClass . getSimpleName ( ) ) ) ; } | Thrown if the class haven t an empty constructor . |
23,773 | protected ChooseConfig searchConfig ( ChooseConfig cc , XML xml ) { ChooseConfig config = searchXmlConfig ( cc , xml ) ; if ( isNull ( config ) ) config = searchAnnotatedConfig ( cc ) ; return config ; } | This method finds the configuration location returns null if don t finds it |
23,774 | private ChooseConfig searchXmlConfig ( ChooseConfig cc , XML xml ) { if ( isNull ( xml . getXmlPath ( ) ) ) return null ; if ( ( isNull ( cc ) || cc == ChooseConfig . DESTINATION ) && xml . isInheritedMapped ( destination ) ) return ChooseConfig . DESTINATION ; if ( ( isNull ( cc ) || cc == ChooseConfig . SOURCE ) && xml . isInheritedMapped ( source ) ) return ChooseConfig . SOURCE ; return null ; } | This method finds the xml configuration returns null if there are no . |
23,775 | private ChooseConfig searchAnnotatedConfig ( ChooseConfig cc ) { if ( ( isNull ( cc ) || cc == ChooseConfig . DESTINATION ) && Annotation . isInheritedMapped ( destination ) ) return ChooseConfig . DESTINATION ; if ( ( isNull ( cc ) || cc == ChooseConfig . SOURCE ) && Annotation . isInheritedMapped ( source ) ) return ChooseConfig . SOURCE ; return null ; } | This method finds the annotations returns null if there are no . |
23,776 | public static JMapAccessor getFieldAccessors ( Class < ? > clazz , Field field ) { return getFieldAccessors ( clazz , field , false , field . getName ( ) , Constants . DEFAULT_FIELD_VALUE ) ; } | Returns JMapAccessor relative to this field null if not present . |
23,777 | private static JMapAccessor getAccessor ( Class < ? > clazz , java . lang . annotation . Annotation [ ] annotations , String fieldName , boolean isOpposite ) { for ( java . lang . annotation . Annotation annotation : annotations ) { if ( annotation . annotationType ( ) == JMapAccessors . class ) { JMapAccessors jmapAccessors = ( JMapAccessors ) annotation ; for ( JMapAccessor jmapAccessor : jmapAccessors . value ( ) ) if ( isValid ( jmapAccessor , fieldName , clazz , isOpposite ) ) return jmapAccessor ; } if ( annotation . annotationType ( ) == JMapAccessor . class ) { JMapAccessor jmapAccessor = ( JMapAccessor ) annotation ; if ( isValid ( jmapAccessor , fieldName , clazz , isOpposite ) ) return jmapAccessor ; } } return null ; } | It finds between annotations if exists a JMapAccessor relative to the field with this name . |
23,778 | public static List < ConversionMethod > getConversionMethods ( Class < ? > clazz ) { List < ConversionMethod > conversions = new ArrayList < ConversionMethod > ( ) ; for ( Method method : getAnnotatedMethods ( clazz ) ) try { conversions . add ( Converter . toConversionMethod ( method ) ) ; } catch ( ConversionParameterException e ) { Error . wrongParameterNumber ( method . getName ( ) , clazz . getSimpleName ( ) ) ; } catch ( DynamicConversionParameterException e ) { Error . parametersUsageNotAllowed ( method . getName ( ) , clazz . getSimpleName ( ) ) ; } catch ( DynamicConversionMethodException e ) { Error . incorrectMethodDefinition ( method . getName ( ) , clazz . getSimpleName ( ) ) ; } catch ( DynamicConversionBodyException e ) { Error . incorrectBodyDefinition ( method . getName ( ) , clazz . getSimpleName ( ) ) ; } return conversions ; } | Returns a list of ConversionMethod that belong to the class given as input . |
23,779 | private static List < Method > getAnnotatedMethods ( Class < ? > clazz ) { List < Method > methods = new ArrayList < Method > ( ) ; for ( Method method : getAllMethods ( clazz ) ) if ( ! isNull ( method . getAnnotation ( JMapConversion . class ) ) ) methods . add ( method ) ; return methods ; } | Returns a list with all annotated methods . |
23,780 | public static boolean isInheritedMapped ( Class < ? > classToCheck ) { for ( Class < ? > clazz : getAllsuperClasses ( classToCheck ) ) if ( ! isNull ( clazz . getAnnotation ( JGlobalMap . class ) ) ) return true ; for ( Field field : getListOfFields ( classToCheck ) ) if ( ! isNull ( field . getAnnotation ( JMap . class ) ) ) return true ; return false ; } | Returns true if the class is configured in annotation false otherwise . |
23,781 | public static ConversionType getConversionType ( final Field destination , final Field source ) { return getConversionType ( destination . getType ( ) , source . getType ( ) ) ; } | Analyzes Fields given as input and returns the type of conversion that has to be done . |
23,782 | public static ConversionType getConversionType ( final Class < ? > destination , final Class < ? > source ) { if ( destination == String . class ) return toStringConversion ( source ) ; if ( destination == Byte . class ) return toByteConversion ( source ) ; if ( destination == byte . class ) return tobyteConversion ( source ) ; if ( destination == Short . class ) return toShortConversion ( source ) ; if ( destination == short . class ) return toshortConversion ( source ) ; if ( destination == Integer . class ) return toIntegerConversion ( source ) ; if ( destination == int . class ) return tointConversion ( source ) ; if ( destination == Long . class ) return toLongConversion ( source ) ; if ( destination == long . class ) return tolongConversion ( source ) ; if ( destination == Float . class ) return toFloatConversion ( source ) ; if ( destination == float . class ) return tofloatConversion ( source ) ; if ( destination == Double . class ) return toDoubleConversion ( source ) ; if ( destination == double . class ) return todoubleConversion ( source ) ; if ( destination == Character . class ) return toCharacterConversion ( source ) ; if ( destination == char . class ) return tocharConversion ( source ) ; if ( destination == Boolean . class ) return toBooleanConversion ( source ) ; if ( destination == boolean . class ) return tobooleanConversion ( source ) ; return UNDEFINED ; } | Analyzes classes given as input and returns the type of conversion that has to be done . |
23,783 | private Class < ? > defineStructure ( Field destination , Field source ) { Class < ? > destinationClass = destination . getType ( ) ; Class < ? > sourceClass = source . getType ( ) ; Class < ? > result = null ; if ( destinationClass . isInterface ( ) ) if ( sourceClass . isInterface ( ) ) result = ( Class < ? > ) implementationClass . get ( destinationClass . getName ( ) ) ; else { Class < ? > sourceInterface = sourceClass . getInterfaces ( ) [ 0 ] ; if ( destinationClass . equals ( sourceInterface ) ) result = sourceClass ; else result = ( Class < ? > ) implementationClass . get ( destinationClass . getName ( ) ) ; } else result = destinationClass ; return result ; } | This method defines the destination structure for this operation . If destination class is an interface a relative implementation will be found . |
23,784 | public static < D , S > IJMapper < D , S > getMapper ( final Class < D > destination , final Class < S > source ) { return getMapper ( destination , source , undefinedConfig ( ) ) ; } | Returns an instance of JMapper from cache if exists in alternative a new instance . |
23,785 | private static String relationalMapperName ( Class < ? > configuredClass , String resource ) { String className = configuredClass . getName ( ) . replaceAll ( "\\." , "" ) ; if ( isEmpty ( resource ) ) return className ; if ( ! isPath ( resource ) ) return write ( className , String . valueOf ( resource . hashCode ( ) ) ) ; String [ ] dep = resource . split ( "\\\\" ) ; if ( dep . length <= 1 ) dep = resource . split ( "/" ) ; String xml = dep [ dep . length - 1 ] ; return write ( className , xml . replaceAll ( "\\." , "" ) . replaceAll ( " " , "" ) ) ; } | Returns a unique name that identify this relationalMapper . |
23,786 | public static Attribute attribute ( String name , String customGet , String customSet ) { return new Attribute ( name , customGet , customSet ) ; } | Permits to define an attribute to map . |
23,787 | public static TargetAttribute targetAttribute ( String name , String customGet , String customSet ) { return new TargetAttribute ( name , customGet , customSet ) ; } | Permits to define a target attribute . |
23,788 | public static LocalAttribute localAttribute ( String name , String customGet , String customSet ) { return new LocalAttribute ( name , customGet , customSet ) ; } | Permits to define a local attribute . |
23,789 | public static void error ( Throwable e ) throws JMapperException { logger . error ( "{}: {}" , e . getClass ( ) . getSimpleName ( ) , e . getMessage ( ) ) ; throw new JMapperException ( e ) ; } | This method handles error log . |
23,790 | protected final StringBuilder write ( StringBuilder sb , final Object ... objects ) { for ( Object string : objects ) sb . append ( string ) ; return sb ; } | This method adds to the sb the objects . |
23,791 | public Method loadMethod ( ) { methodToGenerate = new Method ( ) ; membership = Membership . MAPPER ; methodToGenerate . setClazz ( configClass ) ; Class < ? > destinationClass = destinationField . getType ( ) ; Class < ? > sourceClass = sourceField . getType ( ) ; methodToGenerate . setReturnType ( destinationClass ) ; switch ( methodDefined . getParameterNumber ( ) ) { case ZERO : methodToGenerate . setParameters ( new Class < ? > [ ] { } ) ; break ; case ONE : methodToGenerate . setParameters ( new Class < ? > [ ] { sourceClass } ) ; break ; case TWO : methodToGenerate . setParameters ( new Class < ? > [ ] { destinationClass , sourceClass } ) ; break ; } methodToGenerate . setOriginalName ( methodDefined . getName ( ) ) ; switch ( methodDefined . getType ( ) ) { case STATIC : methodToGenerate . setName ( definedName ( ) ) ; break ; case DYNAMIC : methodToGenerate . setName ( dynamicName ( ) ) ; break ; } methodDefined . setName ( methodToGenerate . getName ( ) ) ; int count = 1 ; String body = "{try{" ; switch ( methodDefined . getParameterNumber ( ) ) { case TWO : String dType = placeholders . get ( destinationTypePattern ) ; String dName = placeholders . get ( destinationPattern ) ; body += dType + " " + dName + " = (" + dType + ") $" + count ++ + ";" + newLine ; case ONE : String sType = placeholders . get ( sourceTypePattern ) ; String sName = placeholders . get ( sourcePattern ) ; body += sType + " " + sName + " = (" + sType + ") $" + count + ";" + newLine ; default : break ; } body += methodDefined . getContent ( ) ; for ( Entry < String , String > pair : placeholders . entrySet ( ) ) if ( ! isNull ( pair . getValue ( ) ) ) body = body . replaceAll ( pair . getKey ( ) , Matcher . quoteReplacement ( pair . getValue ( ) ) ) ; return methodToGenerate . setBody ( body + "}catch(java.lang.Exception e){" + error ( ) + "}return " + defaultPrimitiveValue ( destinationClass ) + ";}" ) ; } | Loads the method to generate . |
23,792 | private String defaultPrimitiveValue ( Class < ? > clazz ) { return clazz == byte . class || clazz == short . class || clazz == int . class ? "0" : clazz == long . class ? "0L" : clazz == float . class ? "0.0f" : clazz == double . class ? "0.0d" : clazz == char . class ? "'\u0000'" : clazz == boolean . class ? "false" : "null" ; } | Returns the default values of primitive types in the form of strings . |
23,793 | private String error ( ) { Map < String , List < ConversionMethod > > conversions = xml . conversionsLoad ( ) ; String methodName = "illegalCode" ; String paramater = "" ; String resource = xml . getXmlPath ( ) ; if ( ! isNull ( resource ) ) { boolean isPath = isPath ( resource ) ; methodName = ! isPath ? "illegalCodeContent" : "illegalCode" ; if ( ! conversions . isEmpty ( ) && ! isNull ( conversions . get ( configClass . getName ( ) ) ) ) { if ( ! isPath ) resource = doubleQuotesHandling ( resource ) ; paramater = write ( ",\"" , resource , "\"" ) ; } } return write ( "com.googlecode.jmapper.config.Error#" , methodName , "(e,\"" , methodToGenerate . getOriginalName ( ) , "\",\"" , configClass . getSimpleName ( ) , "\"" , paramater , ");" ) ; } | This method surrounds the explicit conversion defined with a try - catch to handle null pointers . |
23,794 | public ConversionHandler load ( ConversionAnalyzer analyzer ) { this . methodDefined = analyzer . getMethod ( ) ; this . membership = analyzer . getMembership ( ) ; this . configClass = membership == Membership . DESTINATION ? destinationClass : sourceClass ; this . configurationType = analyzer . getConfigurationType ( ) ; return this ; } | Loads analyzer configurations |
23,795 | public ConversionHandler from ( MappedField sourceMappedField ) { this . sourceField = sourceMappedField . getValue ( ) ; placeholders . put ( sourceTypePattern , sourceField . getType ( ) . getName ( ) ) ; placeholders . put ( sourceNamePattern , sourceField . getName ( ) ) ; placeholders . put ( sourceGetPattern , sourceMappedField . getMethod ( ) ) ; placeholders . put ( sourceSetPattern , sourceMappedField . setMethod ( ) ) ; return this ; } | Source field definition . |
23,796 | public ConversionHandler to ( MappedField destinationMappedField ) { this . destinationField = destinationMappedField . getValue ( ) ; placeholders . put ( destinationTypePattern , destinationField . getType ( ) . getName ( ) ) ; placeholders . put ( destinationNamePattern , destinationField . getName ( ) ) ; placeholders . put ( destinationGetPattern , destinationMappedField . getMethod ( ) ) ; placeholders . put ( destinationSetPattern , destinationMappedField . setMethod ( ) ) ; return this ; } | Destination field definition . |
23,797 | private static synchronized < D , S > IMapper < D , S > createMapper ( MapperBuilder mapper ) throws Throwable { Class < Mapper < D , S > > mapperClass = mapper . exist ( ) ? mapper . < D , S > get ( ) : mapper . < D , S > generate ( ) ; return mapperClass . newInstance ( ) ; } | This method is synchornized to avoid creations of the same instance |
23,798 | public JMapper < D , S > destinationFactory ( DestinationFactory < D > factory ) { this . mapper . setDestinationFactory ( factory ) ; return this ; } | Permits to define a destination factory this is usefull in case of immutable objects . |
23,799 | public static boolean isAssignableFrom ( Class < ? > destination , Class < ? > source ) { return destination . isAssignableFrom ( source ) || isBoxing ( destination , source ) || isUnBoxing ( destination , source ) ; } | Returns true if destination is assignable from source analyzing autoboxing also . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.