
com.workday.autoparse.json.context.ContextHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of autoparse-json Show documentation
Show all versions of autoparse-json Show documentation
A java library built specifically for Android that uses code generation to parse JSON into custom objects in your project.
/*
* Copyright 2016 Workday, Inc.
*
* This software is available under the MIT license.
* Please see the LICENSE.txt file in this project.
*/
package com.workday.autoparse.json.context;
import com.workday.autoparse.json.parser.JsonParserUtils;
/**
* A utility that will return the {@link JsonParserContext} for the current thread.
*
* @author nathan.taylor
* @since 2014-10-09
*/
public class ContextHolder {
private static ThreadLocal context = new ThreadLocal();
private ContextHolder() {
}
/**
* Get the Context for the current thread if one has been set or null if one has not been set.
*/
public static JsonParserContext getContext() {
return context.get();
}
/**
* Set the Context for the current thread. Any calls to {@link JsonParserUtils} from this thread
* will use this Context.
*/
public static void setContext(JsonParserContext context) {
ContextHolder.context.set(context);
}
/**
* Remove the context of the current thread.
*/
public static void removeContext() {
context.remove();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy