mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
improve instanceof usage
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 nosqlbench
|
* Copyright (c) 2022-2023 nosqlbench
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -108,8 +108,8 @@ public class ParsedTemplateMap implements LongFunction<Map<String, ?>>, StaticFi
|
|||||||
this.captures.add(pt.getCaptures());
|
this.captures.add(pt.getCaptures());
|
||||||
switch (pt.getType()) {
|
switch (pt.getType()) {
|
||||||
case literal:
|
case literal:
|
||||||
statics.put(k, ((CharSequence) v).toString());
|
statics.put(k, charvalue.toString());
|
||||||
protomap.put(k, ((CharSequence) v).toString());
|
protomap.put(k, charvalue.toString());
|
||||||
break;
|
break;
|
||||||
case bindref:
|
case bindref:
|
||||||
String spec = pt.asBinding().orElseThrow().getBindspec();
|
String spec = pt.asBinding().orElseThrow().getBindspec();
|
||||||
@@ -126,8 +126,8 @@ public class ParsedTemplateMap implements LongFunction<Map<String, ?>>, StaticFi
|
|||||||
protomap.put(k, null);
|
protomap.put(k, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (v instanceof Map) {
|
} else if (v instanceof Map mapvalue) {
|
||||||
((Map) v).keySet().forEach(smk -> {
|
mapvalue.keySet().forEach(smk -> {
|
||||||
if (!CharSequence.class.isAssignableFrom(smk.getClass())) {
|
if (!CharSequence.class.isAssignableFrom(smk.getClass())) {
|
||||||
throw new OpConfigError("Only string keys are allowed in submaps.");
|
throw new OpConfigError("Only string keys are allowed in submaps.");
|
||||||
}
|
}
|
||||||
@@ -141,8 +141,8 @@ public class ParsedTemplateMap implements LongFunction<Map<String, ?>>, StaticFi
|
|||||||
dynamics.put(k, subtpl);
|
dynamics.put(k, subtpl);
|
||||||
protomap.put(k, null);
|
protomap.put(k, null);
|
||||||
}
|
}
|
||||||
} else if (v instanceof List) {
|
} else if (v instanceof List listvalue) {
|
||||||
List<Object> sublist = (List<Object>) v;
|
List<Object> sublist = listvalue;
|
||||||
ParsedTemplateList subtpl = new ParsedTemplateList(sublist, bindings, cfgsources);
|
ParsedTemplateList subtpl = new ParsedTemplateList(sublist, bindings, cfgsources);
|
||||||
if (subtpl.isStatic()) {
|
if (subtpl.isStatic()) {
|
||||||
statics.put(k, sublist);
|
statics.put(k, sublist);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 nosqlbench
|
* Copyright (c) 2022-2023 nosqlbench
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -50,12 +50,12 @@ public class CharBufferExtract implements LongFunction<CharBuffer> {
|
|||||||
|
|
||||||
public CharBufferExtract(Object initFunc, Object sizeFunc) {
|
public CharBufferExtract(Object initFunc, Object sizeFunc) {
|
||||||
CharBuffer image = null;
|
CharBuffer image = null;
|
||||||
if (initFunc instanceof Number) {
|
if (initFunc instanceof Number number) {
|
||||||
int bufsize = ((Number) initFunc).intValue();
|
int bufsize = number.intValue();
|
||||||
this.image = new CharBufImage(bufsize).apply(1L);
|
this.image = new CharBufImage(bufsize).apply(1L);
|
||||||
} else {
|
} else {
|
||||||
LongFunction<String> bbfunc = VirtDataConversions.adaptFunction(initFunc, LongFunction.class, String.class);
|
LongFunction<String> stringFunc = VirtDataConversions.adaptFunction(initFunc, LongFunction.class, String.class);
|
||||||
this.image = CharBuffer.wrap(bbfunc.apply(0));
|
this.image = CharBuffer.wrap(stringFunc.apply(0));
|
||||||
}
|
}
|
||||||
this.imgsize = this.image.limit();
|
this.imgsize = this.image.limit();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user