Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public ImmutableOpenMap<String, Custom> getCustoms() {
return this.customs;
}

@SuppressWarnings("unchecked")
public <T extends Custom> T custom(String type) {
return (T) customs.get(type);
}
Expand Down Expand Up @@ -366,6 +367,7 @@ public String toString() {
}

@Override
@SuppressWarnings("unchecked")
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
EnumSet<Metric> metrics = Metric.parseString(params.param("metric", "_all"), true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public CompressedXContent source() {
/**
* Converts the serialized compressed form of the mappings into a parsed map.
*/
@SuppressWarnings("unchecked")
public Map<String, Object> sourceAsMap() throws ElasticsearchParseException {
Map<String, Object> mapping = XContentHelper.convertToMap(source.compressedReference(), true).v2();
if (mapping.size() == 1 && mapping.containsKey(type())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ void eviction() {
}

public static final int NUMBER_OF_SEGMENTS = 256;
@SuppressWarnings("unchecked") private final CacheSegment<K, V>[] segments = new CacheSegment[NUMBER_OF_SEGMENTS];
@SuppressWarnings({"unchecked", "rawtypes"})
private final CacheSegment<K, V>[] segments = new CacheSegment[NUMBER_OF_SEGMENTS];

{
for (int i = 0; i < segments.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ public String getName() {
/**
* The first value of the hit.
*/
@SuppressWarnings("unchecked")
public <V> V getValue() {
if (values == null || values.isEmpty()) {
return null;
}
return (V)values.get(0);
return (V) values.get(0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public <T extends NamedWriteable> Entry(Class<T> categoryClass, String name, Wri
/**
* Constructs a new registry from the given entries.
*/
@SuppressWarnings("rawtypes")
public NamedWriteableRegistry(List<Entry> entries) {
if (entries.isEmpty()) {
registry = Collections.emptyMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,12 @@ public final Instant readOptionalInstant() throws IOException {
return present ? readInstant() : null;
}

@SuppressWarnings("unchecked")
private List readArrayList() throws IOException {
private List<Object> readArrayList() throws IOException {
int size = readArraySize();
if (size == 0) {
return Collections.emptyList();
}
List list = new ArrayList(size);
List<Object> list = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
list.add(readGenericValue());
}
Expand Down Expand Up @@ -790,7 +789,7 @@ private Map readLinkedHashMap() throws IOException {
if (size9 == 0) {
return Collections.emptyMap();
}
Map map9 = new LinkedHashMap(size9);
Map<String, Object> map9 = new LinkedHashMap<>(size9);
for (int i = 0; i < size9; i++) {
map9.put(readString(), readGenericValue());
}
Expand All @@ -802,7 +801,7 @@ private Map readHashMap() throws IOException {
if (size10 == 0) {
return Collections.emptyMap();
}
Map map10 = new HashMap(size10);
Map<String, Object> map10 = new HashMap<>(size10);
for (int i = 0; i < size10; i++) {
map10.put(readString(), readGenericValue());
}
Expand Down Expand Up @@ -985,6 +984,7 @@ public <T extends Writeable> T readOptionalWriteable(Writeable.Reader<T> reader)
}
}

@SuppressWarnings("unchecked")
public <T extends Exception> T readException() throws IOException {
if (readBoolean()) {
int key = readVInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public static void cleanLuceneIndex(Directory directory) throws IOException {
}

public static void checkSegmentInfoIntegrity(final Directory directory) throws IOException {
new SegmentInfos.FindSegmentsFile(directory) {
new SegmentInfos.FindSegmentsFile<>(directory) {

@Override
protected Object doBody(String segmentFileName) throws IOException {
Expand Down Expand Up @@ -344,7 +344,7 @@ public static TopDocsAndMaxScore readTopDocs(StreamInput in) throws IOException
}

public static FieldDoc readFieldDoc(StreamInput in) throws IOException {
Comparable[] cFields = new Comparable[in.readVInt()];
Comparable<?>[] cFields = new Comparable<?>[in.readVInt()];
for (int j = 0; j < cFields.length; j++) {
byte type = in.readByte();
if (type == 0) {
Expand Down Expand Up @@ -374,7 +374,7 @@ public static FieldDoc readFieldDoc(StreamInput in) throws IOException {
return new FieldDoc(in.readVInt(), in.readFloat(), cFields);
}

public static Comparable readSortValue(StreamInput in) throws IOException {
public static Comparable<?> readSortValue(StreamInput in) throws IOException {
byte type = in.readByte();
if (type == 0) {
return null;
Expand Down Expand Up @@ -483,7 +483,7 @@ public static void writeSortValue(StreamOutput out, Object field) throws IOExcep
if (field == null) {
out.writeByte((byte) 0);
} else {
Class type = field.getClass();
Class<?> type = field.getClass();
if (type == String.class) {
out.writeByte((byte) 1);
out.writeString((String) field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ public void apply(Map<String, Tuple<A, B>> values, Settings current, Settings pr
* Note: Only settings registered in {@link SettingsModule} can be changed dynamically.
* </p>
*/
@SuppressWarnings("rawtypes")
public synchronized void addAffixGroupUpdateConsumer(List<Setting.AffixSetting<?>> settings, BiConsumer<String, Settings> consumer) {
List<SettingUpdater> affixUpdaters = new ArrayList<>(settings.size());
for (Setting.AffixSetting<?> setting : settings) {
Expand Down Expand Up @@ -503,7 +504,7 @@ void validate(final String key, final Settings settings, final boolean validateD
*/
void validate(
final String key, final Settings settings, final boolean validateDependencies, final boolean validateInternalOrPrivateIndex) {
Setting setting = getRaw(key);
Setting<?> setting = getRaw(key);
if (setting == null) {
LevenshteinDistance ld = new LevenshteinDistance();
List<Tuple<Float, String>> scoredKeys = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public IndexScopedSettings copy(Settings settings, IndexMetaData metaData) {
}

@Override
protected void validateSettingKey(Setting setting) {
protected void validateSettingKey(Setting<?> setting) {
if (setting.getKey().startsWith("index.") == false) {
throw new IllegalArgumentException("illegal settings key: [" + setting.getKey() + "] must start with [index.]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public static void ensureNoSelfReferences(Object value, String messageHint) {
}
}

@SuppressWarnings("unchecked")
private static Iterable<?> convert(Object value) {
if (value == null) {
return null;
Expand Down Expand Up @@ -267,12 +268,13 @@ public static int sortAndDedup(final BytesRefArray bytes, final int[] indices) {

}

@SuppressWarnings("unchecked")
public static <E> ArrayList<E> iterableAsArrayList(Iterable<? extends E> elements) {
if (elements == null) {
throw new NullPointerException("elements");
}
if (elements instanceof Collection) {
return new ArrayList<>((Collection)elements);
return new ArrayList<>((Collection) elements);
} else {
ArrayList<E> list = new ArrayList<>();
for (E element : elements) {
Expand All @@ -282,13 +284,17 @@ public static <E> ArrayList<E> iterableAsArrayList(Iterable<? extends E> element
}
}

@SafeVarargs
@SuppressWarnings("varargs")
public static <E> ArrayList<E> arrayAsArrayList(E... elements) {
if (elements == null) {
throw new NullPointerException("elements");
}
return new ArrayList<>(Arrays.asList(elements));
}

@SafeVarargs
@SuppressWarnings("varargs")
public static <E> ArrayList<E> asArrayList(E first, E... other) {
if (other == null) {
throw new NullPointerException("other");
Expand All @@ -299,6 +305,8 @@ public static <E> ArrayList<E> asArrayList(E first, E... other) {
return list;
}

@SafeVarargs
@SuppressWarnings("varargs")
public static<E> ArrayList<E> asArrayList(E first, E second, E... other) {
if (other == null) {
throw new NullPointerException("other");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ public static <T> HashSet<T> newHashSet(Iterator<T> iterator) {

public static <T> HashSet<T> newHashSet(Iterable<T> iterable) {
Objects.requireNonNull(iterable);
return iterable instanceof Collection ? new HashSet<>((Collection)iterable) : newHashSet(iterable.iterator());
return iterable instanceof Collection ? new HashSet<>((Collection<T>) iterable) : newHashSet(iterable.iterator());
}

@SafeVarargs
@SuppressWarnings("varargs")
public static <T> HashSet<T> newHashSet(T... elements) {
Objects.requireNonNull(elements);
HashSet<T> set = new HashSet<>(elements.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public TerminationHandle warmReader(final IndexShard indexShard, final Elasticse
executor.execute(() -> {
try {
final long start = System.nanoTime();
IndexFieldData.Global ifd = indexFieldDataService.getForField(fieldType);
IndexFieldData.Global<?> ifd = indexFieldDataService.getForField(fieldType);
IndexFieldData<?> global = ifd.loadGlobal(reader);
if (reader.leaves().isEmpty() == false) {
global.load(reader.leaves().get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public GeoPointFieldMapper build(BuilderContext context) {

public static class TypeParser implements Mapper.TypeParser {
@Override
@SuppressWarnings("rawtypes")
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext)
throws MapperParsingException {
Builder builder = new GeoPointFieldMapper.Builder(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ MetadataFieldMapper.Builder<?,?> parse(String name, Map<String, Object> node,
MetadataFieldMapper getDefault(MappedFieldType fieldType, ParserContext parserContext);
}

@SuppressWarnings("rawtypes")
public abstract static class Builder<T extends Builder, Y extends MetadataFieldMapper> extends FieldMapper.Builder<T, Y> {
public Builder(String name, MappedFieldType fieldType, MappedFieldType defaultFieldType) {
super(name, fieldType, defaultFieldType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public boolean isIncludeInRoot() {
}
}

@SuppressWarnings("rawtypes")
public static class Builder<T extends Builder, Y extends ObjectMapper> extends Mapper.Builder<T, Y> {

protected boolean enabled = Defaults.ENABLED;
Expand All @@ -105,6 +106,7 @@ public static class Builder<T extends Builder, Y extends ObjectMapper> extends M

protected final List<Mapper.Builder> mappersBuilders = new ArrayList<>();

@SuppressWarnings("unchecked")
public Builder(String name) {
super(name);
this.builder = (T) this;
Expand All @@ -131,6 +133,7 @@ public T add(Mapper.Builder builder) {
}

@Override
@SuppressWarnings("unchecked")
public Y build(BuilderContext context) {
context.path().add(name);

Expand Down Expand Up @@ -159,9 +162,10 @@ protected ObjectMapper createMapper(String name, String fullPath, boolean enable

public static class TypeParser implements Mapper.TypeParser {
@Override
@SuppressWarnings("rawtypes")
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
ObjectMapper.Builder builder = new Builder(name);
parseNested(name, node, builder, parserContext);
parseNested(name, node, builder);
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, Object> entry = iterator.next();
String fieldName = entry.getKey();
Expand All @@ -173,6 +177,7 @@ public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext
return builder;
}

@SuppressWarnings({"unchecked", "rawtypes"})
protected static boolean parseObjectOrDocumentTypeProperties(String fieldName, Object fieldNode, ParserContext parserContext,
ObjectMapper.Builder builder) {
if (fieldName.equals("dynamic")) {
Expand Down Expand Up @@ -203,8 +208,8 @@ protected static boolean parseObjectOrDocumentTypeProperties(String fieldName, O
return false;
}

protected static void parseNested(String name, Map<String, Object> node, ObjectMapper.Builder builder,
ParserContext parserContext) {
@SuppressWarnings("rawtypes")
protected static void parseNested(String name, Map<String, Object> node, ObjectMapper.Builder builder) {
boolean nested = false;
boolean nestedIncludeInParent = false;
boolean nestedIncludeInRoot = false;
Expand Down Expand Up @@ -236,6 +241,7 @@ protected static void parseNested(String name, Map<String, Object> node, ObjectM

}

@SuppressWarnings("rawtypes")
protected static void parseProperties(ObjectMapper.Builder objBuilder, Map<String, Object> propsNode, ParserContext parserContext) {
Iterator<Map.Entry<String, Object>> iterator = propsNode.entrySet().iterator();
while (iterator.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public RootObjectMapper build(BuilderContext context) {
* @param parentIncluded True iff node is a child of root or a node that is included in
* root
*/
@SuppressWarnings("rawtypes")
private static void fixRedundantIncludes(ObjectMapper.Builder omb, boolean parentIncluded) {
for (Object mapper : omb.mappersBuilders) {
if (mapper instanceof ObjectMapper.Builder) {
Expand Down Expand Up @@ -119,6 +120,7 @@ protected ObjectMapper createMapper(String name, String fullPath, boolean enable
public static class TypeParser extends ObjectMapper.TypeParser {

@Override
@SuppressWarnings("rawtypes")
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {

RootObjectMapper.Builder builder = new Builder(name);
Expand All @@ -135,8 +137,9 @@ public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext
return builder;
}

@SuppressWarnings("unchecked")
protected boolean processField(RootObjectMapper.Builder builder, String fieldName, Object fieldNode,
Version indexVersionCreated) {
Version indexVersionCreated) {
if (fieldName.equals("date_formats") || fieldName.equals("dynamic_date_formats")) {
if (fieldNode instanceof List) {
List<DateFormatter> formatters = new ArrayList<>();
Expand All @@ -154,15 +157,17 @@ protected boolean processField(RootObjectMapper.Builder builder, String fieldNam
}
return true;
} else if (fieldName.equals("dynamic_templates")) {
// "dynamic_templates" : [
// {
// "template_1" : {
// "match" : "*_test",
// "match_mapping_type" : "string",
// "mapping" : { "type" : "string", "store" : "yes" }
// }
// }
// ]
/*
"dynamic_templates" : [
{
"template_1" : {
"match" : "*_test",
"match_mapping_type" : "string",
"mapping" : { "type" : "string", "store" : "yes" }
}
}
]
*/
List<?> tmplNodes = (List<?>) fieldNode;
List<DynamicTemplate> templates = new ArrayList<>();
for (Object tmplNode : tmplNodes) {
Expand Down Expand Up @@ -231,6 +236,7 @@ public DateFormatter[] dynamicDateTimeFormatters() {
return dynamicDateTimeFormatters.value();
}

@SuppressWarnings("rawtypes")
public Mapper.Builder findTemplateBuilder(ParseContext context, String name, XContentFieldType matchType) {
return findTemplateBuilder(context, name, matchType.defaultMappingType(), matchType);
}
Expand All @@ -242,6 +248,7 @@ public Mapper.Builder findTemplateBuilder(ParseContext context, String name, XCo
* @param matchType the type of the field in the json document or null if unknown
* @return a mapper builder, or null if there is no template for such a field
*/
@SuppressWarnings("rawtypes")
public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType, XContentFieldType matchType) {
DynamicTemplate dynamicTemplate = findTemplate(context.path(), name, matchType);
if (dynamicTemplate == null) {
Expand Down
Loading