forked from EsotericSoftware/kryo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request EsotericSoftware#392 from magro/move-generics-to-s…
…erializers Move Generics(Resolver) to serializers, reduce visibility, go back to 3.1.0-SNAPSHOT
- Loading branch information
Showing
10 changed files
with
58 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,18 @@ | |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | ||
|
||
package com.esotericsoftware.kryo; | ||
package com.esotericsoftware.kryo.serializers; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/*** Helper class to map type name variables to concrete classes that are used during instantiation | ||
/** | ||
* INTERNAL API | ||
* | ||
* Helper class to map type name variables to concrete classes that are used during instantiation | ||
* | ||
* @author Roman Levenstein <[email protected]> */ | ||
public class Generics { | ||
final class Generics { | ||
private Map<String, Class> typeVar2class; | ||
|
||
public Generics () { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,36 +17,43 @@ | |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | ||
|
||
package com.esotericsoftware.kryo; | ||
package com.esotericsoftware.kryo.serializers; | ||
|
||
import java.util.LinkedList; | ||
|
||
/** Helper class that resolves a type name variable to a concrete class using the current class serialization stack | ||
import static com.esotericsoftware.minlog.Log.TRACE; | ||
import static com.esotericsoftware.minlog.Log.trace; | ||
|
||
/** | ||
* INTERNAL API | ||
* | ||
* Helper class that resolves a type name variable to a concrete class using the current class serialization stack | ||
* | ||
* @author Jeroen van Erp <[email protected]> */ | ||
public class GenericsResolver { | ||
public final class GenericsResolver { | ||
private LinkedList<Generics> stack = new LinkedList<Generics>(); | ||
|
||
GenericsResolver () { | ||
public GenericsResolver () { | ||
} | ||
|
||
public Class getConcreteClass (String typeVar) { | ||
Class getConcreteClass(String typeVar) { | ||
for (Generics generics : stack) { | ||
Class clazz = generics.getConcreteClass(typeVar); | ||
if (clazz != null) return clazz; | ||
} | ||
return null; | ||
} | ||
|
||
public boolean isSet () { | ||
boolean isSet () { | ||
return !stack.isEmpty(); | ||
} | ||
|
||
void pushScope (Generics scope) { | ||
void pushScope(Class type, Generics scope) { | ||
if (TRACE) trace("generics", "Settting a new generics scope for class " + type.getName() + ": " + scope); | ||
stack.addFirst(scope); | ||
} | ||
|
||
void popScope () { | ||
void popScope() { | ||
stack.removeFirst(); | ||
} | ||
} |