org.opentripplanner.model.json_serialization.BitSetDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.model.json_serialization;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
import java.util.BitSet;
/**
* Deserialize an array [true, false, true . . .] to a bitset
*/
public class BitSetDeserializer extends JsonDeserializer {
@Override public BitSet deserialize(JsonParser jsonParser,
DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
BitSet ret = new BitSet();
int i = 0;
JsonToken token;
while (!JsonToken.END_ARRAY.equals(token = jsonParser.nextValue())) {
if (JsonToken.VALUE_TRUE.equals(token))
ret.set(i);
i++;
}
return ret;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy