com.urbanairship.api.common.parse.MapFieldParserRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
The Urban Airship Java client library
/*
* Copyright (c) 2013-2016. Urban Airship and Contributors
*/
package com.urbanairship.api.common.parse;
import java.util.Map;
import java.util.Optional;
public class MapFieldParserRegistry> implements FieldParserRegistry {
private final Map> registryMap;
private final Optional> defaultParser;
public MapFieldParserRegistry(Map> registryMap) {
this(registryMap, null);
}
public MapFieldParserRegistry(Map> registryMap, FieldParser defaultParser) {
this.registryMap = registryMap;
this.defaultParser = Optional.ofNullable(defaultParser);
}
@Override
public Optional> getFieldParser(String fieldName) {
FieldParser parser = registryMap.get(fieldName);
if (parser == null && defaultParser.isPresent()) {
return defaultParser;
}
return Optional.ofNullable(registryMap.get(fieldName));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy