Package com.cedarsoftware.io.factory
Class SimpleEntryFactory
java.lang.Object
com.cedarsoftware.io.factory.SimpleEntryFactory
- All Implemented Interfaces:
ClassFactory
Factory class to create AbstractMap.SimpleEntry and AbstractMap.SimpleImmutableEntry instances.
These classes have final fields that cannot be set via reflection on Java 9+, so we must use the constructor to create properly initialized instances.
Handles both:
AbstractMap.SimpleEntry- mutable entry (value can be changed)AbstractMap.SimpleImmutableEntry- immutable entry
- Author:
- John DeRegnaucourt (jdereg@gmail.com)
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
License
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true because the entry is fully constructed by this factory.newInstance(Class<?> c, JsonObject jObj, Resolver resolver) Creates a new SimpleEntry or SimpleImmutableEntry instance using values from the JsonObject.
-
Constructor Details
-
SimpleEntryFactory
public SimpleEntryFactory()
-
-
Method Details
-
newInstance
Creates a new SimpleEntry or SimpleImmutableEntry instance using values from the JsonObject.- Specified by:
newInstancein interfaceClassFactory- Parameters:
c- The class to instantiate (SimpleEntry or SimpleImmutableEntry)jObj- The JsonObject containing "key" and "value" fieldsresolver- The resolver for converting nested objects- Returns:
- A new entry instance with the key and value set
-
isObjectFinal
public boolean isObjectFinal()Returns true because the entry is fully constructed by this factory. No further field processing is needed.- Specified by:
isObjectFinalin interfaceClassFactory- Returns:
- true if this object is instantiated and completely filled using the contents from the JsonObject. In this case, no further processing will be performed on the instance. If the object has sub-objects (complex fields), then return false so that json-io will continue filling out the remaining portion of the object.
-