before stringlengths 12 3.21M | after stringlengths 41 3.21M | repo stringlengths 1 56 | type stringclasses 1
value | __index_level_0__ int64 0 442k |
|---|---|---|---|---|
public static ServiceProvider createServiceProvider(final String baseURI, final String genericBaseURI, final String title, final String description, final Publisher publisher, final Class<?>[] resourceClasses) throws OslcCoreApplicationException, URISyntaxException {
new ServiceProvider().setTitle(title);
new ServiceProvider().setDescription(description);
new ServiceProvider().setPublisher(publisher);
final Map<String, Service> serviceMap = new HashMap<String, Service>();
for (final Class<?> resourceClass : resourceClasses) {
final OslcService serviceAnnotation = resourceClass.getAnnotation(OslcService.class);
if (serviceAnnotation == null) {
throw new OslcCoreMissingAnnotationException(resourceClass, OslcService.class);
}
final String domain = serviceAnnotation.value();
Service service = serviceMap.get(domain);
if (service == null) {
service = new Service(new URI(domain));
serviceMap.put(domain, service);
}
Map<String, Object> initPathParameterValues = null;
if (initPathParameterValues == null) {
log.warn("pathParameterValues passed to ServiceProviderFactory.initServiceProvider() SHALL NOT be null");
initPathParameterValues = new HashMap<>();
}
handleResourceClass(baseURI, genericBaseURI, resourceClass, service, initPathParameterValues);
}
for (final Service service : serviceMap.values()) {
new ServiceProvider().addService(service);
}
return new ServiceProvider();
} | public static ServiceProvider createServiceProvider(final String baseURI, final String genericBaseURI, final String title, final String description, final Publisher publisher, final Class<?>[] resourceClasses) throws OslcCoreApplicationException, URISyntaxException {
<DeepExtract>
new ServiceProvider().setTitle(title);
new ServiceProvider().setDescription(description);
new ServiceProvider().setPublisher(publisher);
final Map<String, Service> serviceMap = new HashMap<String, Service>();
for (final Class<?> resourceClass : resourceClasses) {
final OslcService serviceAnnotation = resourceClass.getAnnotation(OslcService.class);
if (serviceAnnotation == null) {
throw new OslcCoreMissingAnnotationException(resourceClass, OslcService.class);
}
final String domain = serviceAnnotation.value();
Service service = serviceMap.get(domain);
if (service == null) {
service = new Service(new URI(domain));
serviceMap.put(domain, service);
}
Map<String, Object> initPathParameterValues = null;
if (initPathParameterValues == null) {
log.warn("pathParameterValues passed to ServiceProviderFactory.initServiceProvider() SHALL NOT be null");
initPathParameterValues = new HashMap<>();
}
handleResourceClass(baseURI, genericBaseURI, resourceClass, service, initPathParameterValues);
}
for (final Service service : serviceMap.values()) {
new ServiceProvider().addService(service);
}
return new ServiceProvider();
</DeepExtract>
} | lyo.core | positive | 426 |
public static ParametersPackage init() {
if (isInited)
return (ParametersPackage) EPackage.Registry.INSTANCE.getEPackage(ParametersPackage.eNS_URI);
ParametersPackageImpl theParametersPackage = (ParametersPackageImpl) (EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ParametersPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ParametersPackageImpl());
isInited = true;
if (isCreated)
return;
isCreated = true;
parameterEClass = createEClass(PARAMETER);
createEAttribute(parameterEClass, PARAMETER__NAME);
createEReference(parameterEClass, PARAMETER__TYPE);
parameterSpecificationEClass = createEClass(PARAMETER_SPECIFICATION);
createEReference(parameterSpecificationEClass, PARAMETER_SPECIFICATION__TYPES);
createEReference(parameterSpecificationEClass, PARAMETER_SPECIFICATION__PARAMETERS);
typeEClass = createEClass(TYPE);
createEAttribute(typeEClass, TYPE__NAME);
createEReference(typeEClass, TYPE__CONSTRAINTS);
compositeTypeEClass = createEClass(COMPOSITE_TYPE);
createEReference(compositeTypeEClass, COMPOSITE_TYPE__INNERTYPES);
basicTypeEClass = createEClass(BASIC_TYPE);
createEAttribute(basicTypeEClass, BASIC_TYPE__ATOMICTYPE);
constraintEClass = createEClass(CONSTRAINT);
createEAttribute(constraintEClass, CONSTRAINT__CONSTRAINT);
atomicTypeEEnum = createEEnum(ATOMIC_TYPE);
if (isInitialized)
return;
isInitialized = true;
setName(eNAME);
setNsPrefix(eNS_PREFIX);
setNsURI(eNS_URI);
compositeTypeEClass.getESuperTypes().add(this.getType());
basicTypeEClass.getESuperTypes().add(this.getType());
initEClass(parameterEClass, Parameter.class, "Parameter", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getParameter_Name(), ecorePackage.getEString(), "name", null, 0, 1, Parameter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getParameter_Type(), this.getType(), null, "type", null, 1, 1, Parameter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(parameterSpecificationEClass, ParameterSpecification.class, "ParameterSpecification", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getParameterSpecification_Types(), this.getType(), null, "types", null, 0, -1, ParameterSpecification.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getParameterSpecification_Parameters(), this.getParameter(), null, "parameters", null, 0, -1, ParameterSpecification.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(typeEClass, Type.class, "Type", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getType_Name(), ecorePackage.getEString(), "name", null, 0, 1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getType_Constraints(), this.getConstraint(), null, "constraints", null, 0, -1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(compositeTypeEClass, CompositeType.class, "CompositeType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getCompositeType_Innertypes(), this.getType(), null, "innertypes", null, 1, -1, CompositeType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(basicTypeEClass, BasicType.class, "BasicType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getBasicType_Atomictype(), this.getAtomicType(), "atomictype", null, 0, 1, BasicType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(constraintEClass, Constraint.class, "Constraint", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getConstraint_Constraint(), ecorePackage.getEString(), "constraint", null, 0, 1, Constraint.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEEnum(atomicTypeEEnum, AtomicType.class, "AtomicType");
addEEnumLiteral(atomicTypeEEnum, AtomicType.STRING);
addEEnumLiteral(atomicTypeEEnum, AtomicType.INTEGER);
addEEnumLiteral(atomicTypeEEnum, AtomicType.BOOLEAN);
addEEnumLiteral(atomicTypeEEnum, AtomicType.FLOAT);
createResource(eNS_URI);
theParametersPackage.freeze();
EPackage.Registry.INSTANCE.put(ParametersPackage.eNS_URI, theParametersPackage);
return theParametersPackage;
} | public static ParametersPackage init() {
if (isInited)
return (ParametersPackage) EPackage.Registry.INSTANCE.getEPackage(ParametersPackage.eNS_URI);
ParametersPackageImpl theParametersPackage = (ParametersPackageImpl) (EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ParametersPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ParametersPackageImpl());
isInited = true;
if (isCreated)
return;
isCreated = true;
parameterEClass = createEClass(PARAMETER);
createEAttribute(parameterEClass, PARAMETER__NAME);
createEReference(parameterEClass, PARAMETER__TYPE);
parameterSpecificationEClass = createEClass(PARAMETER_SPECIFICATION);
createEReference(parameterSpecificationEClass, PARAMETER_SPECIFICATION__TYPES);
createEReference(parameterSpecificationEClass, PARAMETER_SPECIFICATION__PARAMETERS);
typeEClass = createEClass(TYPE);
createEAttribute(typeEClass, TYPE__NAME);
createEReference(typeEClass, TYPE__CONSTRAINTS);
compositeTypeEClass = createEClass(COMPOSITE_TYPE);
createEReference(compositeTypeEClass, COMPOSITE_TYPE__INNERTYPES);
basicTypeEClass = createEClass(BASIC_TYPE);
createEAttribute(basicTypeEClass, BASIC_TYPE__ATOMICTYPE);
constraintEClass = createEClass(CONSTRAINT);
createEAttribute(constraintEClass, CONSTRAINT__CONSTRAINT);
atomicTypeEEnum = createEEnum(ATOMIC_TYPE);
<DeepExtract>
if (isInitialized)
return;
isInitialized = true;
setName(eNAME);
setNsPrefix(eNS_PREFIX);
setNsURI(eNS_URI);
compositeTypeEClass.getESuperTypes().add(this.getType());
basicTypeEClass.getESuperTypes().add(this.getType());
initEClass(parameterEClass, Parameter.class, "Parameter", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getParameter_Name(), ecorePackage.getEString(), "name", null, 0, 1, Parameter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getParameter_Type(), this.getType(), null, "type", null, 1, 1, Parameter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(parameterSpecificationEClass, ParameterSpecification.class, "ParameterSpecification", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getParameterSpecification_Types(), this.getType(), null, "types", null, 0, -1, ParameterSpecification.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getParameterSpecification_Parameters(), this.getParameter(), null, "parameters", null, 0, -1, ParameterSpecification.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(typeEClass, Type.class, "Type", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getType_Name(), ecorePackage.getEString(), "name", null, 0, 1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getType_Constraints(), this.getConstraint(), null, "constraints", null, 0, -1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(compositeTypeEClass, CompositeType.class, "CompositeType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getCompositeType_Innertypes(), this.getType(), null, "innertypes", null, 1, -1, CompositeType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(basicTypeEClass, BasicType.class, "BasicType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getBasicType_Atomictype(), this.getAtomicType(), "atomictype", null, 0, 1, BasicType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(constraintEClass, Constraint.class, "Constraint", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getConstraint_Constraint(), ecorePackage.getEString(), "constraint", null, 0, 1, Constraint.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEEnum(atomicTypeEEnum, AtomicType.class, "AtomicType");
addEEnumLiteral(atomicTypeEEnum, AtomicType.STRING);
addEEnumLiteral(atomicTypeEEnum, AtomicType.INTEGER);
addEEnumLiteral(atomicTypeEEnum, AtomicType.BOOLEAN);
addEEnumLiteral(atomicTypeEEnum, AtomicType.FLOAT);
createResource(eNS_URI);
</DeepExtract>
theParametersPackage.freeze();
EPackage.Registry.INSTANCE.put(ParametersPackage.eNS_URI, theParametersPackage);
return theParametersPackage;
} | IDE | positive | 427 |
public static boolean copyFile(File srcFile, File destFile) {
return copyOrMoveFile(getFileByPath(srcFile), getFileByPath(destFile), false);
} | public static boolean copyFile(File srcFile, File destFile) {
<DeepExtract>
return copyOrMoveFile(getFileByPath(srcFile), getFileByPath(destFile), false);
</DeepExtract>
} | RSUtil | positive | 428 |
public synchronized Snapshot get(String key) throws IOException {
if (journalWriter == null) {
throw new IllegalStateException("cache is closed");
}
Matcher matcher = LEGAL_KEY_PATTERN.matcher(key);
if (!matcher.matches()) {
throw new IllegalArgumentException("keys must match regex " + STRING_KEY_PATTERN + ": \"" + key + "\"");
}
Entry entry = lruEntries.get(key);
if (entry == null) {
return null;
}
if (!entry.readable) {
return null;
}
InputStream[] ins = new InputStream[valueCount];
try {
for (int i = 0; i < valueCount; i++) {
ins[i] = new FileInputStream(entry.getCleanFile(i));
}
} catch (FileNotFoundException e) {
for (int i = 0; i < valueCount; i++) {
if (ins[i] != null) {
CacheUtil.closeQuietly(ins[i]);
} else {
break;
}
}
return null;
}
redundantOpCount++;
journalWriter.append(READ + ' ' + key + '\n');
if (journalRebuildRequired()) {
executorService.submit(cleanupCallable);
}
return new Snapshot(key, entry.sequenceNumber, ins, entry.lengths);
} | public synchronized Snapshot get(String key) throws IOException {
if (journalWriter == null) {
throw new IllegalStateException("cache is closed");
}
<DeepExtract>
Matcher matcher = LEGAL_KEY_PATTERN.matcher(key);
if (!matcher.matches()) {
throw new IllegalArgumentException("keys must match regex " + STRING_KEY_PATTERN + ": \"" + key + "\"");
}
</DeepExtract>
Entry entry = lruEntries.get(key);
if (entry == null) {
return null;
}
if (!entry.readable) {
return null;
}
InputStream[] ins = new InputStream[valueCount];
try {
for (int i = 0; i < valueCount; i++) {
ins[i] = new FileInputStream(entry.getCleanFile(i));
}
} catch (FileNotFoundException e) {
for (int i = 0; i < valueCount; i++) {
if (ins[i] != null) {
CacheUtil.closeQuietly(ins[i]);
} else {
break;
}
}
return null;
}
redundantOpCount++;
journalWriter.append(READ + ' ' + key + '\n');
if (journalRebuildRequired()) {
executorService.submit(cleanupCallable);
}
return new Snapshot(key, entry.sequenceNumber, ins, entry.lengths);
} | WeatherApp | positive | 431 |
public Criteria andUsercodeLessThan(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "usercode" + " cannot be null");
}
criteria.add(new Criterion("usercode <", value));
return (Criteria) this;
} | public Criteria andUsercodeLessThan(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "usercode" + " cannot be null");
}
criteria.add(new Criterion("usercode <", value));
</DeepExtract>
return (Criteria) this;
} | Whome | positive | 432 |
@Override
public Iterator<TemporalObject> temporalObjects(long value) {
final List<Node> nodes = new ArrayList<Node>();
intervalTree.search(value, (Node) intervalTree.root, nodes);
Iterator[] result = new Iterator[nodes.size()];
int i = 0;
for (Node node : nodes) {
GenericTemporalElement tE = dataset.getTemporalElementByRow(node.row);
result[i++] = dataset.getTemporalObjectsByElementId(tE.getId()).iterator();
}
return new CompositeIterator(result);
} | @Override
public Iterator<TemporalObject> temporalObjects(long value) {
final List<Node> nodes = new ArrayList<Node>();
intervalTree.search(value, (Node) intervalTree.root, nodes);
<DeepExtract>
Iterator[] result = new Iterator[nodes.size()];
int i = 0;
for (Node node : nodes) {
GenericTemporalElement tE = dataset.getTemporalElementByRow(node.row);
result[i++] = dataset.getTemporalObjectsByElementId(tE.getId()).iterator();
}
return new CompositeIterator(result);
</DeepExtract>
} | TimeBench | positive | 433 |
@Override
public ResultDTO<Void> enableJob(Long jobId) {
RequestBody body = new FormBody.Builder().add("jobId", jobId.toString()).add("appId", appId.toString()).build();
String post;
String url = getUrl(OpenAPIConstant.ENABLE_JOB, currentAddress);
try {
String res = HttpUtils.post(url, body);
if (StringUtils.isNotEmpty(res)) {
post = res;
}
} catch (IOException e) {
log.warn("[PowerJobClient] request url:{} failed, reason is {}.", url, e.toString());
}
for (String addr : allAddress) {
if (Objects.equals(addr, currentAddress)) {
continue;
}
url = getUrl(OpenAPIConstant.ENABLE_JOB, addr);
try {
String res = HttpUtils.post(url, body);
if (StringUtils.isNotEmpty(res)) {
log.warn("[PowerJobClient] server change: from({}) -> to({}).", currentAddress, addr);
currentAddress = addr;
post = res;
}
} catch (IOException e) {
log.warn("[PowerJobClient] request url:{} failed, reason is {}.", url, e.toString());
}
}
log.error("[PowerJobClient] do post for path: {} failed because of no server available in {}.", OpenAPIConstant.ENABLE_JOB, allAddress);
throw new PowerJobException("no server available when send post request");
return JSON.parseObject(post, VOID_RESULT_TYPE);
} | @Override
public ResultDTO<Void> enableJob(Long jobId) {
RequestBody body = new FormBody.Builder().add("jobId", jobId.toString()).add("appId", appId.toString()).build();
<DeepExtract>
String post;
String url = getUrl(OpenAPIConstant.ENABLE_JOB, currentAddress);
try {
String res = HttpUtils.post(url, body);
if (StringUtils.isNotEmpty(res)) {
post = res;
}
} catch (IOException e) {
log.warn("[PowerJobClient] request url:{} failed, reason is {}.", url, e.toString());
}
for (String addr : allAddress) {
if (Objects.equals(addr, currentAddress)) {
continue;
}
url = getUrl(OpenAPIConstant.ENABLE_JOB, addr);
try {
String res = HttpUtils.post(url, body);
if (StringUtils.isNotEmpty(res)) {
log.warn("[PowerJobClient] server change: from({}) -> to({}).", currentAddress, addr);
currentAddress = addr;
post = res;
}
} catch (IOException e) {
log.warn("[PowerJobClient] request url:{} failed, reason is {}.", url, e.toString());
}
}
log.error("[PowerJobClient] do post for path: {} failed because of no server available in {}.", OpenAPIConstant.ENABLE_JOB, allAddress);
throw new PowerJobException("no server available when send post request");
</DeepExtract>
return JSON.parseObject(post, VOID_RESULT_TYPE);
} | PowerJob | positive | 434 |
public void saveTheme(String theme) {
var configuration = get().orElseThrow();
configuration.changeTheme(theme);
final Configuration configuration = get().orElseThrow();
final Optional<ServerConfiguration> serverConfigurationOpt = getById(configuration.toPersistModel().getId());
if (serverConfigurationOpt.isPresent()) {
configuration.update(configuration.toPersistModel());
} else {
configuration.add(configuration.toPersistModel());
}
prettyZooConfigRepository.save(configuration.toPersistModel());
} | public void saveTheme(String theme) {
var configuration = get().orElseThrow();
configuration.changeTheme(theme);
<DeepExtract>
final Configuration configuration = get().orElseThrow();
final Optional<ServerConfiguration> serverConfigurationOpt = getById(configuration.toPersistModel().getId());
if (serverConfigurationOpt.isPresent()) {
configuration.update(configuration.toPersistModel());
} else {
configuration.add(configuration.toPersistModel());
}
prettyZooConfigRepository.save(configuration.toPersistModel());
</DeepExtract>
} | PrettyZoo | positive | 435 |
@Override
public int computeHorizontalScrollRange(RecyclerView.State state) {
if (getChildCount() == 0) {
return 0;
}
if (!mSmoothScrollbarEnabled) {
return getItemCount();
}
return (int) (getItemCount() * mInterval);
} | @Override
public int computeHorizontalScrollRange(RecyclerView.State state) {
<DeepExtract>
if (getChildCount() == 0) {
return 0;
}
if (!mSmoothScrollbarEnabled) {
return getItemCount();
}
return (int) (getItemCount() * mInterval);
</DeepExtract>
} | RxBanner | positive | 436 |
public Builder buildUpon() {
this.denominator = denominator;
return this;
} | public Builder buildUpon() {
<DeepExtract>
this.denominator = denominator;
return this;
</DeepExtract>
} | mpd-tools | positive | 437 |
public void move(int dx, int dy) {
assert (dx == 0 || 0 == 0);
int ox = this.x, oy = this.y;
this.x += dx;
this.y += 0;
if (this.x < 0 || this.y < 0 || (this.x + this.width) >= Level.toPixel(this.level.width) || (this.y + this.height >= Level.toPixel(this.level.height))) {
this.x = ox;
this.y = oy;
return false;
}
List<Entity> entities = level.getEntityCollisions(this);
for (Entity e : entities) {
if (e != this && this.collides(e) && e.collides(this)) {
this.collide(e);
e.collide(this);
if ((dx != 0 && FMath.sameSign(dx, e.x - this.x)) || (0 != 0 && FMath.sameSign(0, e.y - this.y))) {
this.x = ox;
this.y = oy;
return false;
}
}
}
for (int[] p : level.getTileCollisions(this)) {
Tile t = Tile.TILES[level.getTile(p[0], p[1])];
t.bump(level, p[0], p[1], this);
if (t.collides(level, p[0], p[1], this)) {
this.x = ox;
this.y = oy;
return false;
}
}
return true;
assert (0 == 0 || dy == 0);
int ox = this.x, oy = this.y;
this.x += 0;
this.y += dy;
if (this.x < 0 || this.y < 0 || (this.x + this.width) >= Level.toPixel(this.level.width) || (this.y + this.height >= Level.toPixel(this.level.height))) {
this.x = ox;
this.y = oy;
return false;
}
List<Entity> entities = level.getEntityCollisions(this);
for (Entity e : entities) {
if (e != this && this.collides(e) && e.collides(this)) {
this.collide(e);
e.collide(this);
if ((0 != 0 && FMath.sameSign(0, e.x - this.x)) || (dy != 0 && FMath.sameSign(dy, e.y - this.y))) {
this.x = ox;
this.y = oy;
return false;
}
}
}
for (int[] p : level.getTileCollisions(this)) {
Tile t = Tile.TILES[level.getTile(p[0], p[1])];
t.bump(level, p[0], p[1], this);
if (t.collides(level, p[0], p[1], this)) {
this.x = ox;
this.y = oy;
return false;
}
}
return true;
} | public void move(int dx, int dy) {
assert (dx == 0 || 0 == 0);
int ox = this.x, oy = this.y;
this.x += dx;
this.y += 0;
if (this.x < 0 || this.y < 0 || (this.x + this.width) >= Level.toPixel(this.level.width) || (this.y + this.height >= Level.toPixel(this.level.height))) {
this.x = ox;
this.y = oy;
return false;
}
List<Entity> entities = level.getEntityCollisions(this);
for (Entity e : entities) {
if (e != this && this.collides(e) && e.collides(this)) {
this.collide(e);
e.collide(this);
if ((dx != 0 && FMath.sameSign(dx, e.x - this.x)) || (0 != 0 && FMath.sameSign(0, e.y - this.y))) {
this.x = ox;
this.y = oy;
return false;
}
}
}
for (int[] p : level.getTileCollisions(this)) {
Tile t = Tile.TILES[level.getTile(p[0], p[1])];
t.bump(level, p[0], p[1], this);
if (t.collides(level, p[0], p[1], this)) {
this.x = ox;
this.y = oy;
return false;
}
}
return true;
<DeepExtract>
assert (0 == 0 || dy == 0);
int ox = this.x, oy = this.y;
this.x += 0;
this.y += dy;
if (this.x < 0 || this.y < 0 || (this.x + this.width) >= Level.toPixel(this.level.width) || (this.y + this.height >= Level.toPixel(this.level.height))) {
this.x = ox;
this.y = oy;
return false;
}
List<Entity> entities = level.getEntityCollisions(this);
for (Entity e : entities) {
if (e != this && this.collides(e) && e.collides(this)) {
this.collide(e);
e.collide(this);
if ((0 != 0 && FMath.sameSign(0, e.x - this.x)) || (dy != 0 && FMath.sameSign(dy, e.y - this.y))) {
this.x = ox;
this.y = oy;
return false;
}
}
}
for (int[] p : level.getTileCollisions(this)) {
Tile t = Tile.TILES[level.getTile(p[0], p[1])];
t.bump(level, p[0], p[1], this);
if (t.collides(level, p[0], p[1], this)) {
this.x = ox;
this.y = oy;
return false;
}
}
return true;
</DeepExtract>
} | microcraft | positive | 438 |
@Test
public void testBeyoundCapacitySingleDataItemAccessed() {
int time = 0;
for (int i = 0; i < numCloudletsInSession2; i++) {
twoDataItemsStatSession.notifyOfTime(time++);
WebSession.StepCloudlets currCloudLets = twoDataItemsStatSession.pollCloudlets(time++);
assertNotNull(currCloudLets);
((TestWebCloudlet) currCloudLets.asCloudlet).setFinished(true);
assertEquals(currCloudLets.dbCloudlets.size(), 2);
((TestWebCloudlet) currCloudLets.dbCloudlets.get(0)).setFinished(true);
((TestWebCloudlet) currCloudLets.dbCloudlets.get(1)).setFinished(true);
}
if (i++ % 3 == 0) {
idealStartUpTimes.offer(time++);
}
assertNull(twoDataItemsStatSession.pollCloudlets(time++));
} | @Test
public void testBeyoundCapacitySingleDataItemAccessed() {
int time = 0;
for (int i = 0; i < numCloudletsInSession2; i++) {
twoDataItemsStatSession.notifyOfTime(time++);
WebSession.StepCloudlets currCloudLets = twoDataItemsStatSession.pollCloudlets(time++);
assertNotNull(currCloudLets);
((TestWebCloudlet) currCloudLets.asCloudlet).setFinished(true);
assertEquals(currCloudLets.dbCloudlets.size(), 2);
((TestWebCloudlet) currCloudLets.dbCloudlets.get(0)).setFinished(true);
((TestWebCloudlet) currCloudLets.dbCloudlets.get(1)).setFinished(true);
}
<DeepExtract>
if (i++ % 3 == 0) {
idealStartUpTimes.offer(time++);
}
</DeepExtract>
assertNull(twoDataItemsStatSession.pollCloudlets(time++));
} | CloudSimEx | positive | 439 |
@Override
public void initialize(URL location, ResourceBundle resources) {
try {
adminDTOList = AdminController.getAllAdmins();
} catch (Exception e) {
e.printStackTrace();
}
try {
receptionDTOList = ReceptionController.getAllReceptions();
} catch (Exception e) {
e.printStackTrace();
}
} | @Override
public void initialize(URL location, ResourceBundle resources) {
try {
adminDTOList = AdminController.getAllAdmins();
} catch (Exception e) {
e.printStackTrace();
}
<DeepExtract>
try {
receptionDTOList = ReceptionController.getAllReceptions();
} catch (Exception e) {
e.printStackTrace();
}
</DeepExtract>
} | RentLio | positive | 441 |
public Criteria andPicUrlLike(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "picUrl" + " cannot be null");
}
criteria.add(new Criterion("pic_url like", value));
return (Criteria) this;
} | public Criteria andPicUrlLike(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "picUrl" + " cannot be null");
}
criteria.add(new Criterion("pic_url like", value));
</DeepExtract>
return (Criteria) this;
} | ReptilianDemo | positive | 442 |
public static void parser(PrintWriter out, parse_action_table action_table, parse_reduce_table reduce_table, int start_st, production start_prod, boolean compact_reduces, boolean suppress_scanner) throws internal_error {
long start_time = System.currentTimeMillis();
out.println();
out.println("//----------------------------------------------------");
out.println("// The following code was generated by " + version.title_str);
out.println("// " + new Date());
out.println("//----------------------------------------------------");
out.println();
if (package_name != null) {
out.println("package " + package_name + ";");
out.println();
}
for (int i = 0; i < import_list.size(); i++) out.println("import " + import_list.elementAt(i) + ";");
out.println();
out.println("/** " + version.title_str + " generated parser.");
out.println(" * @version " + new Date());
out.println(" */");
out.println("public class " + parser_class_name + " extends java_cup.runtime.lr_parser {");
out.println();
out.println(" /** Default constructor. */");
out.println(" public " + parser_class_name + "() {super();}");
if (!suppress_scanner) {
out.println();
out.println(" /** Constructor which sets the default scanner. */");
out.println(" public " + parser_class_name + "(java_cup.runtime.Scanner s) {super(s);}");
}
production[] all_prods;
production prod;
long start_time = System.currentTimeMillis();
all_prods = new production[production.number()];
for (Enumeration p = production.all(); p.hasMoreElements(); ) {
prod = (production) p.nextElement();
all_prods[prod.index()] = prod;
}
short[][] prod_table = new short[production.number()][2];
for (int i = 0; i < production.number(); i++) {
prod = all_prods[i];
prod_table[i][0] = (short) prod.lhs().the_symbol().index();
prod_table[i][1] = (short) prod.rhs_length();
}
out.println();
out.println(" /** Production table. */");
out.println(" protected static final short _production_table[][] = ");
out.print(" unpackFromStrings(");
do_table_as_string(out, prod_table);
out.println(");");
out.println();
out.println(" /** Access to production table. */");
out.println(" public short[][] production_table() " + "{return _production_table;}");
production_table_time = System.currentTimeMillis() - start_time;
parse_action_row row;
parse_action act;
int red;
long start_time = System.currentTimeMillis();
short[][] action_table = new short[action_table.num_states()][];
for (int i = 0; i < action_table.num_states(); i++) {
row = action_table.under_state[i];
if (compact_reduces)
row.compute_default();
else
row.default_reduce = -1;
short[] temp_table = new short[2 * row.size()];
int nentries = 0;
for (int j = 0; j < row.size(); j++) {
act = row.under_term[j];
if (act.kind() != parse_action.ERROR) {
if (act.kind() == parse_action.SHIFT) {
temp_table[nentries++] = (short) j;
temp_table[nentries++] = (short) (((shift_action) act).shift_to().index() + 1);
} else if (act.kind() == parse_action.REDUCE) {
red = ((reduce_action) act).reduce_with().index();
if (red != row.default_reduce) {
temp_table[nentries++] = (short) j;
temp_table[nentries++] = (short) (-(red + 1));
}
} else if (act.kind() == parse_action.NONASSOC) {
} else
throw new internal_error("Unrecognized action code " + act.kind() + " found in parse table");
}
}
action_table[i] = new short[nentries + 2];
System.arraycopy(temp_table, 0, action_table[i], 0, nentries);
action_table[i][nentries++] = -1;
if (row.default_reduce != -1)
action_table[i][nentries++] = (short) (-(row.default_reduce + 1));
else
action_table[i][nentries++] = 0;
}
out.println();
out.println(" /** Parse-action table. */");
out.println(" protected static final short[][] _action_table = ");
out.print(" unpackFromStrings(");
do_table_as_string(out, action_table);
out.println(");");
out.println();
out.println(" /** Access to parse-action table. */");
out.println(" public short[][] action_table() {return _action_table;}");
action_table_time = System.currentTimeMillis() - start_time;
lalr_state goto_st;
parse_action act;
long start_time = System.currentTimeMillis();
short[][] reduce_goto_table = new short[reduce_table.num_states()][];
for (int i = 0; i < reduce_table.num_states(); i++) {
short[] temp_table = new short[2 * reduce_table.under_state[i].size()];
int nentries = 0;
for (int j = 0; j < reduce_table.under_state[i].size(); j++) {
goto_st = reduce_table.under_state[i].under_non_term[j];
if (goto_st != null) {
temp_table[nentries++] = (short) j;
temp_table[nentries++] = (short) goto_st.index();
}
}
reduce_goto_table[i] = new short[nentries + 2];
System.arraycopy(temp_table, 0, reduce_goto_table[i], 0, nentries);
reduce_goto_table[i][nentries++] = -1;
reduce_goto_table[i][nentries++] = -1;
}
out.println();
out.println(" /** <code>reduce_goto</code> table. */");
out.println(" protected static final short[][] _reduce_table = ");
out.print(" unpackFromStrings(");
do_table_as_string(out, reduce_goto_table);
out.println(");");
out.println();
out.println(" /** Access to <code>reduce_goto</code> table. */");
out.println(" public short[][] reduce_table() {return _reduce_table;}");
out.println();
goto_table_time = System.currentTimeMillis() - start_time;
out.println(" /** Instance of action encapsulation class. */");
out.println(" protected " + pre("actions") + " action_obj;");
out.println();
out.println(" /** Action encapsulation object initializer. */");
out.println(" protected void init_actions()");
out.println(" {");
out.println(" action_obj = new " + pre("actions") + "(this);");
out.println(" }");
out.println();
out.println(" /** Invoke a user supplied parse action. */");
out.println(" public java_cup.runtime.Symbol do_action(");
out.println(" int act_num,");
out.println(" java_cup.runtime.lr_parser parser,");
out.println(" java.util.Stack stack,");
out.println(" int top)");
out.println(" throws java.lang.Exception");
out.println(" {");
out.println(" /* call code in generated class */");
out.println(" return action_obj." + pre("do_action(") + "act_num, parser, stack, top);");
out.println(" }");
out.println("");
out.println(" /** Indicates start state. */");
out.println(" public int start_state() {return " + start_st + ";}");
out.println(" /** Indicates start production. */");
out.println(" public int start_production() {return " + start_production.index() + ";}");
out.println();
out.println(" /** <code>EOF</code> Symbol index. */");
out.println(" public int EOF_sym() {return " + terminal.EOF.index() + ";}");
out.println();
out.println(" /** <code>error</code> Symbol index. */");
out.println(" public int error_sym() {return " + terminal.error.index() + ";}");
out.println();
if (init_code != null) {
out.println();
out.println(" /** User initialization code. */");
out.println(" public void user_init() throws java.lang.Exception");
out.println(" {");
out.println(init_code);
out.println(" }");
}
if (scan_code != null) {
out.println();
out.println(" /** Scan to get the next Symbol. */");
out.println(" public java_cup.runtime.Symbol scan()");
out.println(" throws java.lang.Exception");
out.println(" {");
out.println(scan_code);
out.println(" }");
}
if (parser_code != null) {
out.println();
out.println(parser_code);
}
out.println("}");
production prod;
long start_time = System.currentTimeMillis();
out.println();
out.println("/** Cup generated class to encapsulate user supplied action code.*/");
out.println("class " + pre("actions") + " {");
if (action_code != null) {
out.println();
out.println(action_code);
}
out.println(" private final " + parser_class_name + " parser;");
out.println();
out.println(" /** Constructor */");
out.println(" " + pre("actions") + "(" + parser_class_name + " parser) {");
out.println(" this.parser = parser;");
out.println(" }");
out.println();
out.println(" /** Method with the actual generated action code. */");
out.println(" public final java_cup.runtime.Symbol " + pre("do_action") + "(");
out.println(" int " + pre("act_num,"));
out.println(" java_cup.runtime.lr_parser " + pre("parser,"));
out.println(" java.util.Stack " + pre("stack,"));
out.println(" int " + pre("top)"));
out.println(" throws java.lang.Exception");
out.println(" {");
out.println(" /* Symbol object for return from actions */");
out.println(" java_cup.runtime.Symbol " + pre("result") + ";");
out.println();
out.println(" /* select the action based on the action number */");
out.println(" switch (" + pre("act_num") + ")");
out.println(" {");
for (Enumeration p = production.all(); p.hasMoreElements(); ) {
prod = (production) p.nextElement();
out.println(" /*. . . . . . . . . . . . . . . . . . . .*/");
out.println(" case " + prod.index() + ": // " + prod.to_simple_string());
out.println(" {");
out.println(" " + prod.lhs().the_symbol().stack_type() + " RESULT = null;");
for (int i = 0; i < prod.rhs_length(); i++) {
if (!(prod.rhs(i) instanceof symbol_part))
continue;
symbol s = ((symbol_part) prod.rhs(i)).the_symbol();
if (!(s instanceof non_terminal))
continue;
if (((non_terminal) s).is_embedded_action == false)
continue;
int index = prod.rhs_length() - i - 1;
out.println(" " + "// propagate RESULT from " + s.name());
out.println(" " + "if ( " + "((java_cup.runtime.Symbol) " + emit.pre("stack") + ".elementAt(" + emit.pre("top") + "-" + index + ")).value != null )");
out.println(" " + "RESULT = " + "(" + prod.lhs().the_symbol().stack_type() + ") " + "((java_cup.runtime.Symbol) " + emit.pre("stack") + ".elementAt(" + emit.pre("top") + "-" + index + ")).value;");
}
if (prod.action() != null && prod.action().code_string() != null && !prod.action().equals(""))
out.println(prod.action().code_string());
if (emit.lr_values()) {
int loffset;
String leftstring, rightstring;
int roffset = 0;
rightstring = "((java_cup.runtime.Symbol)" + emit.pre("stack") + ".elementAt(" + emit.pre("top") + "-" + roffset + ")).right";
if (prod.rhs_length() == 0)
leftstring = rightstring;
else {
loffset = prod.rhs_length() - 1;
leftstring = "((java_cup.runtime.Symbol)" + emit.pre("stack") + ".elementAt(" + emit.pre("top") + "-" + loffset + ")).left";
}
out.println(" " + pre("result") + " = new java_cup.runtime.Symbol(" + prod.lhs().the_symbol().index() + "/*" + prod.lhs().the_symbol().name() + "*/" + ", " + leftstring + ", " + rightstring + ", RESULT);");
} else {
out.println(" " + pre("result") + " = new java_cup.runtime.Symbol(" + prod.lhs().the_symbol().index() + "/*" + prod.lhs().the_symbol().name() + "*/" + ", RESULT);");
}
out.println(" }");
if (prod == start_prod) {
out.println(" /* ACCEPT */");
out.println(" " + pre("parser") + ".done_parsing();");
}
out.println(" return " + pre("result") + ";");
out.println();
}
out.println(" /* . . . . . .*/");
out.println(" default:");
out.println(" throw new Exception(");
out.println(" \"Invalid action number found in " + "internal parse table\");");
out.println();
out.println(" }");
out.println(" }");
out.println("}");
out.println();
action_code_time = System.currentTimeMillis() - start_time;
parser_time = System.currentTimeMillis() - start_time;
} | public static void parser(PrintWriter out, parse_action_table action_table, parse_reduce_table reduce_table, int start_st, production start_prod, boolean compact_reduces, boolean suppress_scanner) throws internal_error {
long start_time = System.currentTimeMillis();
out.println();
out.println("//----------------------------------------------------");
out.println("// The following code was generated by " + version.title_str);
out.println("// " + new Date());
out.println("//----------------------------------------------------");
out.println();
if (package_name != null) {
out.println("package " + package_name + ";");
out.println();
}
for (int i = 0; i < import_list.size(); i++) out.println("import " + import_list.elementAt(i) + ";");
out.println();
out.println("/** " + version.title_str + " generated parser.");
out.println(" * @version " + new Date());
out.println(" */");
out.println("public class " + parser_class_name + " extends java_cup.runtime.lr_parser {");
out.println();
out.println(" /** Default constructor. */");
out.println(" public " + parser_class_name + "() {super();}");
if (!suppress_scanner) {
out.println();
out.println(" /** Constructor which sets the default scanner. */");
out.println(" public " + parser_class_name + "(java_cup.runtime.Scanner s) {super(s);}");
}
production[] all_prods;
production prod;
long start_time = System.currentTimeMillis();
all_prods = new production[production.number()];
for (Enumeration p = production.all(); p.hasMoreElements(); ) {
prod = (production) p.nextElement();
all_prods[prod.index()] = prod;
}
short[][] prod_table = new short[production.number()][2];
for (int i = 0; i < production.number(); i++) {
prod = all_prods[i];
prod_table[i][0] = (short) prod.lhs().the_symbol().index();
prod_table[i][1] = (short) prod.rhs_length();
}
out.println();
out.println(" /** Production table. */");
out.println(" protected static final short _production_table[][] = ");
out.print(" unpackFromStrings(");
do_table_as_string(out, prod_table);
out.println(");");
out.println();
out.println(" /** Access to production table. */");
out.println(" public short[][] production_table() " + "{return _production_table;}");
production_table_time = System.currentTimeMillis() - start_time;
parse_action_row row;
parse_action act;
int red;
long start_time = System.currentTimeMillis();
short[][] action_table = new short[action_table.num_states()][];
for (int i = 0; i < action_table.num_states(); i++) {
row = action_table.under_state[i];
if (compact_reduces)
row.compute_default();
else
row.default_reduce = -1;
short[] temp_table = new short[2 * row.size()];
int nentries = 0;
for (int j = 0; j < row.size(); j++) {
act = row.under_term[j];
if (act.kind() != parse_action.ERROR) {
if (act.kind() == parse_action.SHIFT) {
temp_table[nentries++] = (short) j;
temp_table[nentries++] = (short) (((shift_action) act).shift_to().index() + 1);
} else if (act.kind() == parse_action.REDUCE) {
red = ((reduce_action) act).reduce_with().index();
if (red != row.default_reduce) {
temp_table[nentries++] = (short) j;
temp_table[nentries++] = (short) (-(red + 1));
}
} else if (act.kind() == parse_action.NONASSOC) {
} else
throw new internal_error("Unrecognized action code " + act.kind() + " found in parse table");
}
}
action_table[i] = new short[nentries + 2];
System.arraycopy(temp_table, 0, action_table[i], 0, nentries);
action_table[i][nentries++] = -1;
if (row.default_reduce != -1)
action_table[i][nentries++] = (short) (-(row.default_reduce + 1));
else
action_table[i][nentries++] = 0;
}
out.println();
out.println(" /** Parse-action table. */");
out.println(" protected static final short[][] _action_table = ");
out.print(" unpackFromStrings(");
do_table_as_string(out, action_table);
out.println(");");
out.println();
out.println(" /** Access to parse-action table. */");
out.println(" public short[][] action_table() {return _action_table;}");
action_table_time = System.currentTimeMillis() - start_time;
lalr_state goto_st;
parse_action act;
long start_time = System.currentTimeMillis();
short[][] reduce_goto_table = new short[reduce_table.num_states()][];
for (int i = 0; i < reduce_table.num_states(); i++) {
short[] temp_table = new short[2 * reduce_table.under_state[i].size()];
int nentries = 0;
for (int j = 0; j < reduce_table.under_state[i].size(); j++) {
goto_st = reduce_table.under_state[i].under_non_term[j];
if (goto_st != null) {
temp_table[nentries++] = (short) j;
temp_table[nentries++] = (short) goto_st.index();
}
}
reduce_goto_table[i] = new short[nentries + 2];
System.arraycopy(temp_table, 0, reduce_goto_table[i], 0, nentries);
reduce_goto_table[i][nentries++] = -1;
reduce_goto_table[i][nentries++] = -1;
}
out.println();
out.println(" /** <code>reduce_goto</code> table. */");
out.println(" protected static final short[][] _reduce_table = ");
out.print(" unpackFromStrings(");
do_table_as_string(out, reduce_goto_table);
out.println(");");
out.println();
out.println(" /** Access to <code>reduce_goto</code> table. */");
out.println(" public short[][] reduce_table() {return _reduce_table;}");
out.println();
goto_table_time = System.currentTimeMillis() - start_time;
out.println(" /** Instance of action encapsulation class. */");
out.println(" protected " + pre("actions") + " action_obj;");
out.println();
out.println(" /** Action encapsulation object initializer. */");
out.println(" protected void init_actions()");
out.println(" {");
out.println(" action_obj = new " + pre("actions") + "(this);");
out.println(" }");
out.println();
out.println(" /** Invoke a user supplied parse action. */");
out.println(" public java_cup.runtime.Symbol do_action(");
out.println(" int act_num,");
out.println(" java_cup.runtime.lr_parser parser,");
out.println(" java.util.Stack stack,");
out.println(" int top)");
out.println(" throws java.lang.Exception");
out.println(" {");
out.println(" /* call code in generated class */");
out.println(" return action_obj." + pre("do_action(") + "act_num, parser, stack, top);");
out.println(" }");
out.println("");
out.println(" /** Indicates start state. */");
out.println(" public int start_state() {return " + start_st + ";}");
out.println(" /** Indicates start production. */");
out.println(" public int start_production() {return " + start_production.index() + ";}");
out.println();
out.println(" /** <code>EOF</code> Symbol index. */");
out.println(" public int EOF_sym() {return " + terminal.EOF.index() + ";}");
out.println();
out.println(" /** <code>error</code> Symbol index. */");
out.println(" public int error_sym() {return " + terminal.error.index() + ";}");
out.println();
if (init_code != null) {
out.println();
out.println(" /** User initialization code. */");
out.println(" public void user_init() throws java.lang.Exception");
out.println(" {");
out.println(init_code);
out.println(" }");
}
if (scan_code != null) {
out.println();
out.println(" /** Scan to get the next Symbol. */");
out.println(" public java_cup.runtime.Symbol scan()");
out.println(" throws java.lang.Exception");
out.println(" {");
out.println(scan_code);
out.println(" }");
}
if (parser_code != null) {
out.println();
out.println(parser_code);
}
out.println("}");
<DeepExtract>
production prod;
long start_time = System.currentTimeMillis();
out.println();
out.println("/** Cup generated class to encapsulate user supplied action code.*/");
out.println("class " + pre("actions") + " {");
if (action_code != null) {
out.println();
out.println(action_code);
}
out.println(" private final " + parser_class_name + " parser;");
out.println();
out.println(" /** Constructor */");
out.println(" " + pre("actions") + "(" + parser_class_name + " parser) {");
out.println(" this.parser = parser;");
out.println(" }");
out.println();
out.println(" /** Method with the actual generated action code. */");
out.println(" public final java_cup.runtime.Symbol " + pre("do_action") + "(");
out.println(" int " + pre("act_num,"));
out.println(" java_cup.runtime.lr_parser " + pre("parser,"));
out.println(" java.util.Stack " + pre("stack,"));
out.println(" int " + pre("top)"));
out.println(" throws java.lang.Exception");
out.println(" {");
out.println(" /* Symbol object for return from actions */");
out.println(" java_cup.runtime.Symbol " + pre("result") + ";");
out.println();
out.println(" /* select the action based on the action number */");
out.println(" switch (" + pre("act_num") + ")");
out.println(" {");
for (Enumeration p = production.all(); p.hasMoreElements(); ) {
prod = (production) p.nextElement();
out.println(" /*. . . . . . . . . . . . . . . . . . . .*/");
out.println(" case " + prod.index() + ": // " + prod.to_simple_string());
out.println(" {");
out.println(" " + prod.lhs().the_symbol().stack_type() + " RESULT = null;");
for (int i = 0; i < prod.rhs_length(); i++) {
if (!(prod.rhs(i) instanceof symbol_part))
continue;
symbol s = ((symbol_part) prod.rhs(i)).the_symbol();
if (!(s instanceof non_terminal))
continue;
if (((non_terminal) s).is_embedded_action == false)
continue;
int index = prod.rhs_length() - i - 1;
out.println(" " + "// propagate RESULT from " + s.name());
out.println(" " + "if ( " + "((java_cup.runtime.Symbol) " + emit.pre("stack") + ".elementAt(" + emit.pre("top") + "-" + index + ")).value != null )");
out.println(" " + "RESULT = " + "(" + prod.lhs().the_symbol().stack_type() + ") " + "((java_cup.runtime.Symbol) " + emit.pre("stack") + ".elementAt(" + emit.pre("top") + "-" + index + ")).value;");
}
if (prod.action() != null && prod.action().code_string() != null && !prod.action().equals(""))
out.println(prod.action().code_string());
if (emit.lr_values()) {
int loffset;
String leftstring, rightstring;
int roffset = 0;
rightstring = "((java_cup.runtime.Symbol)" + emit.pre("stack") + ".elementAt(" + emit.pre("top") + "-" + roffset + ")).right";
if (prod.rhs_length() == 0)
leftstring = rightstring;
else {
loffset = prod.rhs_length() - 1;
leftstring = "((java_cup.runtime.Symbol)" + emit.pre("stack") + ".elementAt(" + emit.pre("top") + "-" + loffset + ")).left";
}
out.println(" " + pre("result") + " = new java_cup.runtime.Symbol(" + prod.lhs().the_symbol().index() + "/*" + prod.lhs().the_symbol().name() + "*/" + ", " + leftstring + ", " + rightstring + ", RESULT);");
} else {
out.println(" " + pre("result") + " = new java_cup.runtime.Symbol(" + prod.lhs().the_symbol().index() + "/*" + prod.lhs().the_symbol().name() + "*/" + ", RESULT);");
}
out.println(" }");
if (prod == start_prod) {
out.println(" /* ACCEPT */");
out.println(" " + pre("parser") + ".done_parsing();");
}
out.println(" return " + pre("result") + ";");
out.println();
}
out.println(" /* . . . . . .*/");
out.println(" default:");
out.println(" throw new Exception(");
out.println(" \"Invalid action number found in " + "internal parse table\");");
out.println();
out.println(" }");
out.println(" }");
out.println("}");
out.println();
action_code_time = System.currentTimeMillis() - start_time;
</DeepExtract>
parser_time = System.currentTimeMillis() - start_time;
} | Compiler | positive | 443 |
private void jTextFieldRst0ActionPerformed(java.awt.event.ActionEvent evt) {
boolean tick = o.engine.isFunction(jTextFieldRst0.getText());
vanishTickMark();
if ("Rst0".equalsIgnoreCase("Rst0")) {
if (tick)
jLabelTickRst0.setVisible(true);
else
jLabelCrossRst0.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst1")) {
if (tick)
jLabelTickRst1.setVisible(true);
else
jLabelCrossRst1.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst2")) {
if (tick)
jLabelTickRst2.setVisible(true);
else
jLabelCrossRst2.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst3")) {
if (tick)
jLabelTickRst3.setVisible(true);
else
jLabelCrossRst3.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst4")) {
if (tick)
jLabelTickRst4.setVisible(true);
else
jLabelCrossRst4.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst5")) {
if (tick)
jLabelTickRst5.setVisible(true);
else
jLabelCrossRst5.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst6")) {
if (tick)
jLabelTickRst6.setVisible(true);
else
jLabelCrossRst6.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst7")) {
if (tick)
jLabelTickRst7.setVisible(true);
else
jLabelCrossRst7.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst55")) {
if (tick)
jLabelTickRst55.setVisible(true);
else
jLabelCrossRst55.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst65")) {
if (tick)
jLabelTickRst65.setVisible(true);
else
jLabelCrossRst65.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst75")) {
if (tick)
jLabelTickRst75.setVisible(true);
else
jLabelCrossRst75.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Trap")) {
if (tick)
jLabelTickTrap.setVisible(true);
else
jLabelCrossTrap.setVisible(true);
}
if (tick) {
jTextFieldRst0.setText(o.engine.funcLabeltofuncCode(jTextFieldRst0.getText()));
}
} | private void jTextFieldRst0ActionPerformed(java.awt.event.ActionEvent evt) {
boolean tick = o.engine.isFunction(jTextFieldRst0.getText());
<DeepExtract>
vanishTickMark();
if ("Rst0".equalsIgnoreCase("Rst0")) {
if (tick)
jLabelTickRst0.setVisible(true);
else
jLabelCrossRst0.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst1")) {
if (tick)
jLabelTickRst1.setVisible(true);
else
jLabelCrossRst1.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst2")) {
if (tick)
jLabelTickRst2.setVisible(true);
else
jLabelCrossRst2.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst3")) {
if (tick)
jLabelTickRst3.setVisible(true);
else
jLabelCrossRst3.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst4")) {
if (tick)
jLabelTickRst4.setVisible(true);
else
jLabelCrossRst4.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst5")) {
if (tick)
jLabelTickRst5.setVisible(true);
else
jLabelCrossRst5.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst6")) {
if (tick)
jLabelTickRst6.setVisible(true);
else
jLabelCrossRst6.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst7")) {
if (tick)
jLabelTickRst7.setVisible(true);
else
jLabelCrossRst7.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst55")) {
if (tick)
jLabelTickRst55.setVisible(true);
else
jLabelCrossRst55.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst65")) {
if (tick)
jLabelTickRst65.setVisible(true);
else
jLabelCrossRst65.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Rst75")) {
if (tick)
jLabelTickRst75.setVisible(true);
else
jLabelCrossRst75.setVisible(true);
} else if ("Rst0".equalsIgnoreCase("Trap")) {
if (tick)
jLabelTickTrap.setVisible(true);
else
jLabelCrossTrap.setVisible(true);
}
</DeepExtract>
if (tick) {
jTextFieldRst0.setText(o.engine.funcLabeltofuncCode(jTextFieldRst0.getText()));
}
} | 8085simulator | positive | 444 |
@Override
protected void onDetachedFromWindow() {
if (!mRunning) {
return;
}
mRunning = false;
mObjectAnimatorAngle.cancel();
mObjectAnimatorSweep.cancel();
super.onDetachedFromWindow();
} | @Override
protected void onDetachedFromWindow() {
<DeepExtract>
if (!mRunning) {
return;
}
mRunning = false;
mObjectAnimatorAngle.cancel();
mObjectAnimatorSweep.cancel();
</DeepExtract>
super.onDetachedFromWindow();
} | MyBlogDemo | positive | 445 |
public Criteria andCommentCountIn(List<Integer> values) {
if (values == null) {
throw new RuntimeException("Value for " + "commentCount" + " cannot be null");
}
criteria.add(new Criterion("comment_count in", values));
return (Criteria) this;
} | public Criteria andCommentCountIn(List<Integer> values) {
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "commentCount" + " cannot be null");
}
criteria.add(new Criterion("comment_count in", values));
</DeepExtract>
return (Criteria) this;
} | community | positive | 446 |
@Override
public void onClick(View view) {
if (isAniming) {
return;
}
if (mContainer.getVisibility() == View.VISIBLE) {
hideMenu();
return;
}
mContainer.setVisibility(VISIBLE);
animateCircle(0, mScreenWidth, new ToolbarCollapseListener(true));
} | @Override
public void onClick(View view) {
if (isAniming) {
return;
}
if (mContainer.getVisibility() == View.VISIBLE) {
hideMenu();
return;
}
<DeepExtract>
mContainer.setVisibility(VISIBLE);
animateCircle(0, mScreenWidth, new ToolbarCollapseListener(true));
</DeepExtract>
} | AndroidBlog | positive | 447 |
@Override
public void onDestroy() {
try {
if (wakeLock != null) {
wakeLock.release();
}
Tracker.get().stopTracking();
undoSoundVolume();
Speaker.clear();
SensorProducer.clear();
BeepBeeper.clear();
NumericViewUpdater.clear();
DataAccessObject.clear();
Donate.get().clear();
if (Preferences.use_sensbox) {
BTScanner.get().clear();
}
Logger.get().log("App terminated...");
Logger.get().close();
} catch (Throwable ex) {
Logger.get().log("Fail terminating awake " + ex.getMessage());
}
super.onDestroy();
} | @Override
public void onDestroy() {
<DeepExtract>
try {
if (wakeLock != null) {
wakeLock.release();
}
Tracker.get().stopTracking();
undoSoundVolume();
Speaker.clear();
SensorProducer.clear();
BeepBeeper.clear();
NumericViewUpdater.clear();
DataAccessObject.clear();
Donate.get().clear();
if (Preferences.use_sensbox) {
BTScanner.get().clear();
}
Logger.get().log("App terminated...");
Logger.get().close();
} catch (Throwable ex) {
Logger.get().log("Fail terminating awake " + ex.getMessage());
}
</DeepExtract>
super.onDestroy();
} | AVario | positive | 448 |
public Criteria andUsernameIsNull() {
if ("userName is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("userName is null"));
return (Criteria) this;
} | public Criteria andUsernameIsNull() {
<DeepExtract>
if ("userName is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("userName is null"));
</DeepExtract>
return (Criteria) this;
} | Examination_System | positive | 449 |
public TypeK nextElement() {
if (_idx != 0 && _nextV == null)
throw new NoSuchElementException();
_prevK = _nextK;
_prevV = _nextV;
_nextV = null;
while (_idx < length()) {
_nextK = key(_idx++);
if (_nextK != null && _nextK != TOMBSTONE && (_nextV = get(_nextK)) != null)
break;
}
return _prevV;
} | public TypeK nextElement() {
<DeepExtract>
if (_idx != 0 && _nextV == null)
throw new NoSuchElementException();
_prevK = _nextK;
_prevV = _nextV;
_nextV = null;
while (_idx < length()) {
_nextK = key(_idx++);
if (_nextK != null && _nextK != TOMBSTONE && (_nextV = get(_nextK)) != null)
break;
}
return _prevV;
</DeepExtract>
} | high-scale-java-lib | positive | 450 |
private void enq(MutationNode<P1, P2, P3, C> myNode, int TID) {
long phase = maxPhase() + 1;
state.set(TID, new OpDesc<P1, P2, P3, C>(phase, true, myNode));
for (int i = 0; i < state.length(); i++) {
OpDesc<P1, P2, P3, C> desc = state.get(i);
if (desc.pending && desc.phase <= phase) {
help_enq(i, phase);
}
}
final MutationNode<P1, P2, P3, C> last = tail;
final MutationNode<P1, P2, P3, C> next = last.next;
if (next != null) {
int tid = next.enqTid;
final OpDesc<P1, P2, P3, C> curDesc = state.get(tid);
if (last == tail && state.get(tid).node == next) {
final OpDesc<P1, P2, P3, C> newDesc = new OpDesc<P1, P2, P3, C>(state.get(tid).phase, false, next);
state.compareAndSet(tid, curDesc, newDesc);
casTail(last, next);
}
}
} | private void enq(MutationNode<P1, P2, P3, C> myNode, int TID) {
long phase = maxPhase() + 1;
state.set(TID, new OpDesc<P1, P2, P3, C>(phase, true, myNode));
for (int i = 0; i < state.length(); i++) {
OpDesc<P1, P2, P3, C> desc = state.get(i);
if (desc.pending && desc.phase <= phase) {
help_enq(i, phase);
}
}
<DeepExtract>
final MutationNode<P1, P2, P3, C> last = tail;
final MutationNode<P1, P2, P3, C> next = last.next;
if (next != null) {
int tid = next.enqTid;
final OpDesc<P1, P2, P3, C> curDesc = state.get(tid);
if (last == tail && state.get(tid).node == next) {
final OpDesc<P1, P2, P3, C> newDesc = new OpDesc<P1, P2, P3, C>(state.get(tid).phase, false, next);
state.compareAndSet(tid, curDesc, newDesc);
casTail(last, next);
}
}
</DeepExtract>
} | ConcurrencyFreaks | positive | 451 |
public void mouseExited(java.awt.event.MouseEvent evt) {
btn_comment_materials.setBackground(BUTTON_BACKGROUD_COLOR__UNSELECTED_STATE);
} | public void mouseExited(java.awt.event.MouseEvent evt) {
<DeepExtract>
btn_comment_materials.setBackground(BUTTON_BACKGROUD_COLOR__UNSELECTED_STATE);
</DeepExtract>
} | ERSN-OpenMC | positive | 452 |
@Subscribe
public void receiveSubscribe(WalletSubscribeUpdate walletSubscribeUpdate) {
if (wallet != null) {
binding.setWallet(wallet);
if (wallet.getAccountBalanceBananoRaw() != null) {
if (wallet.getAccountBalanceBananoRaw().compareTo(new BigDecimal(0)) == 1) {
binding.homeSendButton.setEnabled(true);
binding.homeSendButton.setBackground(getResources().getDrawable(R.drawable.bg_solid_button));
} else {
binding.homeSendButton.setEnabled(false);
binding.homeSendButton.setBackground(getResources().getDrawable(R.drawable.bg_solid_button_disabled));
}
binding.bananoPlaceholder.setVisibility(View.GONE);
binding.amountBananoSymbol.setVisibility(View.VISIBLE);
binding.amountBananoTitle.setVisibility(View.VISIBLE);
switch(sharedPreferencesUtil.getPriceConversion()) {
case BTC:
binding.btcPrice.setVisibility(View.VISIBLE);
binding.amountLocalCurrencyTitle.setVisibility(View.VISIBLE);
binding.nanoPrice.setVisibility(View.GONE);
break;
case NANO:
binding.nanoPrice.setVisibility(View.VISIBLE);
binding.amountLocalCurrencyTitle.setVisibility(View.VISIBLE);
binding.btcPrice.setVisibility(View.GONE);
break;
default:
binding.nanoPrice.setVisibility(View.GONE);
binding.btcPrice.setVisibility(View.GONE);
binding.amountLocalCurrencyTitle.setVisibility(View.GONE);
break;
}
String balBanano = wallet.getAccountBalanceBanano();
binding.amountBananoTitle.setText(balBanano);
if (balBanano.length() >= 9 && balBanano.length() < 12) {
binding.amountBananoTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.main_balance_md_text));
} else if (balBanano.length() >= 12) {
binding.amountBananoTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.main_balance_sm_text));
} else {
binding.amountBananoTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.main_balance_lg_text));
}
} else {
binding.homeSendButton.setEnabled(false);
binding.homeSendButton.setBackground(getResources().getDrawable(R.drawable.bg_solid_button_disabled));
}
}
if (wallet.getOpenBlock() == null) {
binding.introText.exampleIntroText.setText(UIUtil.colorizeBanano(binding.introText.exampleIntroText.getText().toString(), getContext()));
binding.loadingAnimation.setVisibility(View.GONE);
binding.exampleCards.setVisibility(View.VISIBLE);
} else if (mIntroUri != null) {
Address address = new Address(mIntroUri);
if (address.isValidAddress()) {
if (getActivity() instanceof WindowControl) {
SendDialogFragment dialog = SendDialogFragment.newInstance(address.getAddress(), address.getAmount());
dialog.show(((WindowControl) getActivity()).getFragmentUtility().getFragmentManager(), SendDialogFragment.TAG);
((WindowControl) getActivity()).getFragmentUtility().getFragmentManager().executePendingTransactions();
}
}
mIntroUri = null;
}
} | @Subscribe
public void receiveSubscribe(WalletSubscribeUpdate walletSubscribeUpdate) {
<DeepExtract>
if (wallet != null) {
binding.setWallet(wallet);
if (wallet.getAccountBalanceBananoRaw() != null) {
if (wallet.getAccountBalanceBananoRaw().compareTo(new BigDecimal(0)) == 1) {
binding.homeSendButton.setEnabled(true);
binding.homeSendButton.setBackground(getResources().getDrawable(R.drawable.bg_solid_button));
} else {
binding.homeSendButton.setEnabled(false);
binding.homeSendButton.setBackground(getResources().getDrawable(R.drawable.bg_solid_button_disabled));
}
binding.bananoPlaceholder.setVisibility(View.GONE);
binding.amountBananoSymbol.setVisibility(View.VISIBLE);
binding.amountBananoTitle.setVisibility(View.VISIBLE);
switch(sharedPreferencesUtil.getPriceConversion()) {
case BTC:
binding.btcPrice.setVisibility(View.VISIBLE);
binding.amountLocalCurrencyTitle.setVisibility(View.VISIBLE);
binding.nanoPrice.setVisibility(View.GONE);
break;
case NANO:
binding.nanoPrice.setVisibility(View.VISIBLE);
binding.amountLocalCurrencyTitle.setVisibility(View.VISIBLE);
binding.btcPrice.setVisibility(View.GONE);
break;
default:
binding.nanoPrice.setVisibility(View.GONE);
binding.btcPrice.setVisibility(View.GONE);
binding.amountLocalCurrencyTitle.setVisibility(View.GONE);
break;
}
String balBanano = wallet.getAccountBalanceBanano();
binding.amountBananoTitle.setText(balBanano);
if (balBanano.length() >= 9 && balBanano.length() < 12) {
binding.amountBananoTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.main_balance_md_text));
} else if (balBanano.length() >= 12) {
binding.amountBananoTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.main_balance_sm_text));
} else {
binding.amountBananoTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.main_balance_lg_text));
}
} else {
binding.homeSendButton.setEnabled(false);
binding.homeSendButton.setBackground(getResources().getDrawable(R.drawable.bg_solid_button_disabled));
}
}
</DeepExtract>
if (wallet.getOpenBlock() == null) {
binding.introText.exampleIntroText.setText(UIUtil.colorizeBanano(binding.introText.exampleIntroText.getText().toString(), getContext()));
binding.loadingAnimation.setVisibility(View.GONE);
binding.exampleCards.setVisibility(View.VISIBLE);
} else if (mIntroUri != null) {
Address address = new Address(mIntroUri);
if (address.isValidAddress()) {
if (getActivity() instanceof WindowControl) {
SendDialogFragment dialog = SendDialogFragment.newInstance(address.getAddress(), address.getAmount());
dialog.show(((WindowControl) getActivity()).getFragmentUtility().getFragmentManager(), SendDialogFragment.TAG);
((WindowControl) getActivity()).getFragmentUtility().getFragmentManager().executePendingTransactions();
}
}
mIntroUri = null;
}
} | kalium-android-wallet | positive | 453 |
public void changed(ProgressEvent e) {
if (e.total <= 0 || e.total < e.current) {
return;
}
isLoading = true;
if (JWebBrowser.this.loadingProgress != e.current == e.total ? 100 : Math.min(e.current * 100 / e.total, 99)) {
JWebBrowser.this.loadingProgress = e.current == e.total ? 100 : Math.min(e.current * 100 / e.total, 99);
WebBrowserEvent e = null;
for (int i = listenerList.size() - 1; i >= 0; i--) {
if (e == null) {
e = new WebBrowserEvent(JWebBrowser.this);
}
listenerList.get(i).loadingProgressChanged(e);
}
}
} | public void changed(ProgressEvent e) {
if (e.total <= 0 || e.total < e.current) {
return;
}
isLoading = true;
<DeepExtract>
if (JWebBrowser.this.loadingProgress != e.current == e.total ? 100 : Math.min(e.current * 100 / e.total, 99)) {
JWebBrowser.this.loadingProgress = e.current == e.total ? 100 : Math.min(e.current * 100 / e.total, 99);
WebBrowserEvent e = null;
for (int i = listenerList.size() - 1; i >= 0; i--) {
if (e == null) {
e = new WebBrowserEvent(JWebBrowser.this);
}
listenerList.get(i).loadingProgressChanged(e);
}
}
</DeepExtract>
} | DJ-Sweet | positive | 454 |
public static <T> Class<T> getSecondSuperClassGenricType(final Class clazz) {
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
return Object.class;
}
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (1 >= params.length || 1 < 0) {
return Object.class;
}
if (!(params[1] instanceof Class)) {
return Object.class;
}
return (Class) params[1];
} | public static <T> Class<T> getSecondSuperClassGenricType(final Class clazz) {
<DeepExtract>
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
return Object.class;
}
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (1 >= params.length || 1 < 0) {
return Object.class;
}
if (!(params[1] instanceof Class)) {
return Object.class;
}
return (Class) params[1];
</DeepExtract>
} | database-oop | positive | 455 |
@Test
public void testPatchSearchableField() throws Exception {
String newBrandName = "Shisano";
Supplier<SearchResult> searchCall = () -> doSimpleSearch(newBrandName.toLowerCase());
SearchResultSlice searchResultSlice = searchCall.get().slices.get(0);
assumeTrue(searchResultSlice.matchCount == 0 || searchResultSlice.matchCount > 1);
getImportClient().patchDocuments(indexName, Arrays.asList(new Document("001").set("brand", newBrandName), new Document("003").set("title", "bike light compatible with " + newBrandName)));
getElasticsearchClient().performRequest(new Request("POST", indexName + "/_flush/synced"));
Unreliables.retryUntilTrue(10, TimeUnit.SECONDS, () -> getSearchClient().getDocument(indexName, "001").data.get("brand").equals(newBrandName));
assertThat(getSearchClient().getDocument(indexName, "001").data.get("brand")).isEqualTo(newBrandName);
Unreliables.retryUntilTrue(10, TimeUnit.SECONDS, () -> searchCall.get().slices.get(0).matchCount > 0);
SearchResultSlice searchResultSlice2 = searchCall.get().slices.get(0);
assertThat(searchResultSlice2.matchCount).isEqualTo(2);
Optional<Facet> brandFacet = searchResultSlice2.facets.stream().filter(facet -> facet.fieldName.equals("brand")).findFirst();
assertTrue(brandFacet.isPresent(), () -> "expecting brand facet present, but was not part of facets: " + searchResultSlice2.facets.stream().map(Facet::getFieldName).collect(Collectors.joining(" ")));
assertTrue(brandFacet.get().entries.stream().anyMatch(entry -> newBrandName.equals(entry.getKey())), () -> "expecting brand facet to contain '" + newBrandName + "' but was not part of entries:" + brandFacet.get().entries.stream().map(FacetEntry::getKey).collect(Collectors.joining(" ")));
} | @Test
public void testPatchSearchableField() throws Exception {
String newBrandName = "Shisano";
Supplier<SearchResult> searchCall = () -> doSimpleSearch(newBrandName.toLowerCase());
SearchResultSlice searchResultSlice = searchCall.get().slices.get(0);
assumeTrue(searchResultSlice.matchCount == 0 || searchResultSlice.matchCount > 1);
getImportClient().patchDocuments(indexName, Arrays.asList(new Document("001").set("brand", newBrandName), new Document("003").set("title", "bike light compatible with " + newBrandName)));
<DeepExtract>
getElasticsearchClient().performRequest(new Request("POST", indexName + "/_flush/synced"));
</DeepExtract>
Unreliables.retryUntilTrue(10, TimeUnit.SECONDS, () -> getSearchClient().getDocument(indexName, "001").data.get("brand").equals(newBrandName));
assertThat(getSearchClient().getDocument(indexName, "001").data.get("brand")).isEqualTo(newBrandName);
Unreliables.retryUntilTrue(10, TimeUnit.SECONDS, () -> searchCall.get().slices.get(0).matchCount > 0);
SearchResultSlice searchResultSlice2 = searchCall.get().slices.get(0);
assertThat(searchResultSlice2.matchCount).isEqualTo(2);
Optional<Facet> brandFacet = searchResultSlice2.facets.stream().filter(facet -> facet.fieldName.equals("brand")).findFirst();
assertTrue(brandFacet.isPresent(), () -> "expecting brand facet present, but was not part of facets: " + searchResultSlice2.facets.stream().map(Facet::getFieldName).collect(Collectors.joining(" ")));
assertTrue(brandFacet.get().entries.stream().anyMatch(entry -> newBrandName.equals(entry.getKey())), () -> "expecting brand facet to contain '" + newBrandName + "' but was not part of entries:" + brandFacet.get().entries.stream().map(FacetEntry::getKey).collect(Collectors.joining(" ")));
} | open-commerce-search | positive | 457 |
public static int getPopupDefaultResolution(Context context, List<VideoStream> videoStreams) {
SharedPreferences defaultPreferences = PreferenceManager.getDefaultSharedPreferences(context);
if (defaultPreferences == null)
return 0;
String defaultResolution = defaultPreferences.getString(context.getString(R.string.default_popup_resolution_key), context.getString(R.string.default_popup_resolution_value));
String preferredFormat = defaultPreferences.getString(context.getString(R.string.preferred_video_format_key), context.getString(R.string.preferred_video_format_default));
if (defaultResolution.equals("Best resolution")) {
return 0;
}
int selectedFormat = 0;
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (defaultResolution.equals(item.resolution)) {
selectedFormat = i;
}
}
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (defaultResolution.equals(item.resolution) && preferredFormat.equals(MediaFormat.getNameById(item.format))) {
selectedFormat = i;
}
}
if (selectedFormat == 0 && !videoStreams.get(selectedFormat).resolution.contains(defaultResolution.replace("p60", "p"))) {
String replace = defaultResolution.replace("p60", "p");
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (replace.equals(item.resolution))
selectedFormat = i;
}
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (replace.equals(item.resolution) && preferredFormat.equals(MediaFormat.getNameById(item.format))) {
selectedFormat = i;
}
}
}
return selectedFormat;
} | public static int getPopupDefaultResolution(Context context, List<VideoStream> videoStreams) {
SharedPreferences defaultPreferences = PreferenceManager.getDefaultSharedPreferences(context);
if (defaultPreferences == null)
return 0;
String defaultResolution = defaultPreferences.getString(context.getString(R.string.default_popup_resolution_key), context.getString(R.string.default_popup_resolution_value));
String preferredFormat = defaultPreferences.getString(context.getString(R.string.preferred_video_format_key), context.getString(R.string.preferred_video_format_default));
<DeepExtract>
if (defaultResolution.equals("Best resolution")) {
return 0;
}
int selectedFormat = 0;
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (defaultResolution.equals(item.resolution)) {
selectedFormat = i;
}
}
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (defaultResolution.equals(item.resolution) && preferredFormat.equals(MediaFormat.getNameById(item.format))) {
selectedFormat = i;
}
}
if (selectedFormat == 0 && !videoStreams.get(selectedFormat).resolution.contains(defaultResolution.replace("p60", "p"))) {
String replace = defaultResolution.replace("p60", "p");
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (replace.equals(item.resolution))
selectedFormat = i;
}
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (replace.equals(item.resolution) && preferredFormat.equals(MediaFormat.getNameById(item.format))) {
selectedFormat = i;
}
}
}
return selectedFormat;
</DeepExtract>
} | Float-Tube | positive | 458 |
private int getLeelazEngineVersion() {
List<String> listCommandsResponse = null;
ListenableFuture<List<String>> future = gtpClient.postCommand("list_commands");
try {
listCommandsResponse = future.get(5, TimeUnit.SECONDS);
} catch (ExecutionException | TimeoutException | InterruptedException e) {
}
if (!GtpCommand.isSuccessfulResponse(listCommandsResponse)) {
throw new GenericLizzieException(ImmutableMap.of(REASON, ENGINE_NOT_FUNCTION));
}
GtpCommand.removeResponseHeaderInPlace(listCommandsResponse);
assert listCommandsResponse != null;
boolean isOldVersion = listCommandsResponse.stream().noneMatch(s -> StringUtils.equalsIgnoreCase(s.trim(), "lz-analyze"));
if (isOldVersion) {
return 0;
}
OfficialV2LeelazEngineDetector detector = new OfficialV2LeelazEngineDetector();
gtpClient.registerStdoutLineConsumer(detector);
try {
gtpClient.postCommand("lz-analyze 20", true, null);
if (!detector.latch.await(8, TimeUnit.SECONDS)) {
throw new GenericLizzieException(ImmutableMap.of(REASON, ENGINE_NOT_SUPPORTED));
}
gtpClient.sendCommand("name");
} catch (InterruptedException e) {
} finally {
gtpClient.unregisterStdoutLineConsumer(detector);
}
return detector.version;
} | private int getLeelazEngineVersion() {
List<String> listCommandsResponse = null;
ListenableFuture<List<String>> future = gtpClient.postCommand("list_commands");
try {
listCommandsResponse = future.get(5, TimeUnit.SECONDS);
} catch (ExecutionException | TimeoutException | InterruptedException e) {
}
if (!GtpCommand.isSuccessfulResponse(listCommandsResponse)) {
throw new GenericLizzieException(ImmutableMap.of(REASON, ENGINE_NOT_FUNCTION));
}
GtpCommand.removeResponseHeaderInPlace(listCommandsResponse);
assert listCommandsResponse != null;
boolean isOldVersion = listCommandsResponse.stream().noneMatch(s -> StringUtils.equalsIgnoreCase(s.trim(), "lz-analyze"));
if (isOldVersion) {
return 0;
}
<DeepExtract>
OfficialV2LeelazEngineDetector detector = new OfficialV2LeelazEngineDetector();
gtpClient.registerStdoutLineConsumer(detector);
try {
gtpClient.postCommand("lz-analyze 20", true, null);
if (!detector.latch.await(8, TimeUnit.SECONDS)) {
throw new GenericLizzieException(ImmutableMap.of(REASON, ENGINE_NOT_SUPPORTED));
}
gtpClient.sendCommand("name");
} catch (InterruptedException e) {
} finally {
gtpClient.unregisterStdoutLineConsumer(detector);
}
return detector.version;
</DeepExtract>
} | mylizzie | positive | 459 |
public static VerifyCode generateMathCaptcha(int width, int height) {
LineCaptcha captcha = CaptchaUtil.createLineCaptcha(width, height, DEFAULT_CODE_COUNT, DEFAULT_DISTURB_NUM);
captcha.setGenerator(new MathGenerator());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
captcha.write(bos);
VerifyCode code = new VerifyCode(Base64.encode(bos.toByteArray()), captcha.getCode(), IdUtil.simpleUUID(), null);
try {
bos.close();
} catch (IOException e) {
}
return code;
} | public static VerifyCode generateMathCaptcha(int width, int height) {
LineCaptcha captcha = CaptchaUtil.createLineCaptcha(width, height, DEFAULT_CODE_COUNT, DEFAULT_DISTURB_NUM);
captcha.setGenerator(new MathGenerator());
<DeepExtract>
ByteArrayOutputStream bos = new ByteArrayOutputStream();
captcha.write(bos);
VerifyCode code = new VerifyCode(Base64.encode(bos.toByteArray()), captcha.getCode(), IdUtil.simpleUUID(), null);
try {
bos.close();
} catch (IOException e) {
}
return code;
</DeepExtract>
} | base-spring-boot | positive | 460 |
@NonNull
public Number sum(@NonNull String column) {
final StringBuilder sql = new StringBuilder("SELECT ").append("SUM").append(LEFT_PARENTHESIS).append(column).append(RIGHT_PARENTHESIS).append(" FROM ").append(SQLiteSchema.resolveTable(mType));
if (!TextUtils.isEmpty(mWhere)) {
sql.append(WHERE).append(mWhere);
}
final Cursor cursor = SQLite.obtainClient().query(sql.toString(), Lists.toArray(mBindArgs, Object.class));
try {
if (cursor.moveToFirst()) {
return cursor.getDouble(0);
}
} finally {
IOUtils.closeQuietly(cursor);
}
return Double.NaN;
} | @NonNull
public Number sum(@NonNull String column) {
<DeepExtract>
final StringBuilder sql = new StringBuilder("SELECT ").append("SUM").append(LEFT_PARENTHESIS).append(column).append(RIGHT_PARENTHESIS).append(" FROM ").append(SQLiteSchema.resolveTable(mType));
if (!TextUtils.isEmpty(mWhere)) {
sql.append(WHERE).append(mWhere);
}
final Cursor cursor = SQLite.obtainClient().query(sql.toString(), Lists.toArray(mBindArgs, Object.class));
try {
if (cursor.moveToFirst()) {
return cursor.getDouble(0);
}
} finally {
IOUtils.closeQuietly(cursor);
}
return Double.NaN;
</DeepExtract>
} | droidkit-v5x | positive | 461 |
@Override
protected boolean doUpload(GlucoseDataSet glucoseDataSet) throws IOException {
return upsert(getCollection(), toBasicDBObject(glucoseDataSet));
} | @Override
protected boolean doUpload(GlucoseDataSet glucoseDataSet) throws IOException {
<DeepExtract>
return upsert(getCollection(), toBasicDBObject(glucoseDataSet));
</DeepExtract>
} | android-uploader | positive | 462 |
public Criteria andIdNotEqualTo(Long value) {
if (value == null) {
throw new RuntimeException("Value for " + "id" + " cannot be null");
}
criteria.add(new Criterion("id <>", value));
return (Criteria) this;
} | public Criteria andIdNotEqualTo(Long value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "id" + " cannot be null");
}
criteria.add(new Criterion("id <>", value));
</DeepExtract>
return (Criteria) this;
} | AnyMock | positive | 463 |
private void loadFromFile(File file) throws IOException {
try {
String type = new DataInputStream(new FileInputStream(file)).readUTF();
if (type.equals("jergometer session")) {
int format = Integer.parseInt(new DataInputStream(new FileInputStream(file)).readUTF());
if (format <= 2) {
startTime = new Time(new DataInputStream(new FileInputStream(file)).readLong());
programName = new DataInputStream(new FileInputStream(file)).readUTF();
MiniDataRecord regularSum = new MiniDataRecord(new DataInputStream(new FileInputStream(file)));
int pulseCount = new DataInputStream(new FileInputStream(file)).readInt();
lastRecordRegular = new DataRecord(new DataInputStream(new FileInputStream(file)));
if (format >= 2) {
programDuration = new DataInputStream(new FileInputStream(file)).readInt();
}
int duration = new DataInputStream(new FileInputStream(file)).readInt();
data = new ArrayList<MiniDataRecord>(duration);
for (int i = 0; i < duration; i++) {
data.add(new MiniDataRecord(new DataInputStream(new FileInputStream(file))));
}
statsRegular = new StatsRecord(regularSum.getPulse(), regularSum.getPower(), regularSum.getPedalRpm(), duration, pulseCount);
statsTotal = statsRegular;
currentStats = null;
} else if (format == 3) {
startTime = new Time(new DataInputStream(new FileInputStream(file)).readLong());
programName = new DataInputStream(new FileInputStream(file)).readUTF();
programDuration = new DataInputStream(new FileInputStream(file)).readInt();
lastRecordRegular = new DataRecord(new DataInputStream(new FileInputStream(file)));
lastRecordTotal = new DataRecord(new DataInputStream(new FileInputStream(file)));
statsRegular = new StatsRecord(new DataInputStream(new FileInputStream(file)));
statsTotal = new StatsRecord(new DataInputStream(new FileInputStream(file)));
int dataSize = new DataInputStream(new FileInputStream(file)).readInt();
data = new ArrayList<MiniDataRecord>(dataSize);
for (int i = 0; i < dataSize; i++) {
data.add(new MiniDataRecord(new DataInputStream(new FileInputStream(file))));
}
int pulseSize = new DataInputStream(new FileInputStream(file)).readInt();
for (int i = 0; i < pulseSize; i++) {
pulseAfterSession.add(new DataInputStream(new FileInputStream(file)).readInt());
}
} else {
throw new IOException("Session format " + format + " too new for this version of JErgometer. Seems you need to update JErgometer.");
}
} else {
throw new IOException("File \"" + file.getName() + "\" is not a valid session file.");
}
} catch (EOFException e) {
throw new IOException("Session file corrupted (too short). Please report this bug at jergometer.org.");
}
onlyMiniInfo = false;
} | private void loadFromFile(File file) throws IOException {
<DeepExtract>
try {
String type = new DataInputStream(new FileInputStream(file)).readUTF();
if (type.equals("jergometer session")) {
int format = Integer.parseInt(new DataInputStream(new FileInputStream(file)).readUTF());
if (format <= 2) {
startTime = new Time(new DataInputStream(new FileInputStream(file)).readLong());
programName = new DataInputStream(new FileInputStream(file)).readUTF();
MiniDataRecord regularSum = new MiniDataRecord(new DataInputStream(new FileInputStream(file)));
int pulseCount = new DataInputStream(new FileInputStream(file)).readInt();
lastRecordRegular = new DataRecord(new DataInputStream(new FileInputStream(file)));
if (format >= 2) {
programDuration = new DataInputStream(new FileInputStream(file)).readInt();
}
int duration = new DataInputStream(new FileInputStream(file)).readInt();
data = new ArrayList<MiniDataRecord>(duration);
for (int i = 0; i < duration; i++) {
data.add(new MiniDataRecord(new DataInputStream(new FileInputStream(file))));
}
statsRegular = new StatsRecord(regularSum.getPulse(), regularSum.getPower(), regularSum.getPedalRpm(), duration, pulseCount);
statsTotal = statsRegular;
currentStats = null;
} else if (format == 3) {
startTime = new Time(new DataInputStream(new FileInputStream(file)).readLong());
programName = new DataInputStream(new FileInputStream(file)).readUTF();
programDuration = new DataInputStream(new FileInputStream(file)).readInt();
lastRecordRegular = new DataRecord(new DataInputStream(new FileInputStream(file)));
lastRecordTotal = new DataRecord(new DataInputStream(new FileInputStream(file)));
statsRegular = new StatsRecord(new DataInputStream(new FileInputStream(file)));
statsTotal = new StatsRecord(new DataInputStream(new FileInputStream(file)));
int dataSize = new DataInputStream(new FileInputStream(file)).readInt();
data = new ArrayList<MiniDataRecord>(dataSize);
for (int i = 0; i < dataSize; i++) {
data.add(new MiniDataRecord(new DataInputStream(new FileInputStream(file))));
}
int pulseSize = new DataInputStream(new FileInputStream(file)).readInt();
for (int i = 0; i < pulseSize; i++) {
pulseAfterSession.add(new DataInputStream(new FileInputStream(file)).readInt());
}
} else {
throw new IOException("Session format " + format + " too new for this version of JErgometer. Seems you need to update JErgometer.");
}
} else {
throw new IOException("File \"" + file.getName() + "\" is not a valid session file.");
}
} catch (EOFException e) {
throw new IOException("Session file corrupted (too short). Please report this bug at jergometer.org.");
}
</DeepExtract>
onlyMiniInfo = false;
} | JErgometer | positive | 465 |
@Test
public void stepInCaptureTest() {
assertEquals(2, 2);
assertEquals(2, 2);
assertEquals(2, 2);
assertEquals(2, 2);
} | @Test
public void stepInCaptureTest() {
<DeepExtract>
assertEquals(2, 2);
assertEquals(2, 2);
</DeepExtract>
assertEquals(2, 2);
assertEquals(2, 2);
} | sahagin-java | positive | 466 |
public String getString(int index) throws IOException {
InputStream in;
synchronized (DiskLruCache.this) {
if (entry.currentEditor != this) {
throw new IllegalStateException();
}
if (!entry.readable) {
in = null;
}
in = new FileInputStream(entry.getCleanFile(index));
}
return in != null ? inputStreamToString(in) : null;
} | public String getString(int index) throws IOException {
<DeepExtract>
InputStream in;
synchronized (DiskLruCache.this) {
if (entry.currentEditor != this) {
throw new IllegalStateException();
}
if (!entry.readable) {
in = null;
}
in = new FileInputStream(entry.getCleanFile(index));
}
</DeepExtract>
return in != null ? inputStreamToString(in) : null;
} | socket-rxjava | positive | 467 |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Analytics.init(this);
setContentView(R.layout.list);
database = new Database(this);
database.open();
cursor = database.getSubscriptions();
startManagingCursor(cursor);
if (cursor.getCount() == 0)
Utils.showEmpty(this, R.string.notifications_empty);
setListAdapter(new SubscriptionAdapter(this, cursor));
} | @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Analytics.init(this);
setContentView(R.layout.list);
database = new Database(this);
database.open();
cursor = database.getSubscriptions();
startManagingCursor(cursor);
<DeepExtract>
if (cursor.getCount() == 0)
Utils.showEmpty(this, R.string.notifications_empty);
setListAdapter(new SubscriptionAdapter(this, cursor));
</DeepExtract>
} | congress-android | positive | 468 |
@Test
@Deployment(resources = { "org/camunda/bpm/scenario/test/boundary/ConditionalBoundaryEventTest.bpmn" })
public void testConditionInitiallyFalseAndSetTrue() {
when(scenario.waitsAtUserTask("UserTask")).thenReturn(new UserTaskAction() {
@Override
public void execute(TaskDelegate task) {
rule.getRuntimeService().setVariable(task.getProcessInstance().getId(), "condition", true);
}
});
throw new Exception();
verify(scenario, times(1)).hasStarted("UserTask");
verify(scenario, times(1)).hasFinished("UserTask");
verify(scenario, times(1)).hasFinished("ConditionalBoundaryEvent");
verify(scenario, never()).hasFinished("EndEventAfterUserTask");
verify(scenario, times(1)).hasFinished("EndEventAfterBoundaryEvent");
} | @Test
@Deployment(resources = { "org/camunda/bpm/scenario/test/boundary/ConditionalBoundaryEventTest.bpmn" })
public void testConditionInitiallyFalseAndSetTrue() {
when(scenario.waitsAtUserTask("UserTask")).thenReturn(new UserTaskAction() {
@Override
public void execute(TaskDelegate task) {
rule.getRuntimeService().setVariable(task.getProcessInstance().getId(), "condition", true);
}
});
<DeepExtract>
throw new Exception();
</DeepExtract>
verify(scenario, times(1)).hasStarted("UserTask");
verify(scenario, times(1)).hasFinished("UserTask");
verify(scenario, times(1)).hasFinished("ConditionalBoundaryEvent");
verify(scenario, never()).hasFinished("EndEventAfterUserTask");
verify(scenario, times(1)).hasFinished("EndEventAfterBoundaryEvent");
} | camunda-platform-scenario | positive | 469 |
public static void showLong(@StringRes final int resId, final Object... args) {
show(String.format(Utils.getApp().getResources().getString(resId), args), Toast.LENGTH_LONG);
} | public static void showLong(@StringRes final int resId, final Object... args) {
<DeepExtract>
show(String.format(Utils.getApp().getResources().getString(resId), args), Toast.LENGTH_LONG);
</DeepExtract>
} | CommonLibrary | positive | 471 |
private void drawSmoothPath(Canvas canvas, final Line line) {
linePaint.setStrokeWidth(ChartUtils.dp2px(density, line.getStrokeWidth()));
linePaint.setColor(line.getColor());
linePaint.setPathEffect(line.getPathEffect());
final int lineSize = line.getValues().size();
float prePreviousPointX = Float.NaN;
float prePreviousPointY = Float.NaN;
float previousPointX = Float.NaN;
float previousPointY = Float.NaN;
float currentPointX = Float.NaN;
float currentPointY = Float.NaN;
float nextPointX = Float.NaN;
float nextPointY = Float.NaN;
for (int valueIndex = 0; valueIndex < lineSize; ++valueIndex) {
if (Float.isNaN(currentPointX)) {
PointValue linePoint = line.getValues().get(valueIndex);
currentPointX = computator.computeRawX(linePoint.getX());
currentPointY = computator.computeRawY(linePoint.getY());
}
if (Float.isNaN(previousPointX)) {
if (valueIndex > 0) {
PointValue linePoint = line.getValues().get(valueIndex - 1);
previousPointX = computator.computeRawX(linePoint.getX());
previousPointY = computator.computeRawY(linePoint.getY());
} else {
previousPointX = currentPointX;
previousPointY = currentPointY;
}
}
if (Float.isNaN(prePreviousPointX)) {
if (valueIndex > 1) {
PointValue linePoint = line.getValues().get(valueIndex - 2);
prePreviousPointX = computator.computeRawX(linePoint.getX());
prePreviousPointY = computator.computeRawY(linePoint.getY());
} else {
prePreviousPointX = previousPointX;
prePreviousPointY = previousPointY;
}
}
if (valueIndex < lineSize - 1) {
PointValue linePoint = line.getValues().get(valueIndex + 1);
nextPointX = computator.computeRawX(linePoint.getX());
nextPointY = computator.computeRawY(linePoint.getY());
} else {
nextPointX = currentPointX;
nextPointY = currentPointY;
}
if (valueIndex == 0) {
path.moveTo(currentPointX, currentPointY);
} else {
final float firstDiffX = (currentPointX - prePreviousPointX);
final float firstDiffY = (currentPointY - prePreviousPointY);
final float secondDiffX = (nextPointX - previousPointX);
final float secondDiffY = (nextPointY - previousPointY);
final float firstControlPointX = previousPointX + (LINE_SMOOTHNESS * firstDiffX);
final float firstControlPointY = previousPointY + (LINE_SMOOTHNESS * firstDiffY);
final float secondControlPointX = currentPointX - (LINE_SMOOTHNESS * secondDiffX);
final float secondControlPointY = currentPointY - (LINE_SMOOTHNESS * secondDiffY);
path.cubicTo(firstControlPointX, firstControlPointY, secondControlPointX, secondControlPointY, currentPointX, currentPointY);
}
prePreviousPointX = previousPointX;
prePreviousPointY = previousPointY;
previousPointX = currentPointX;
previousPointY = currentPointY;
currentPointX = nextPointX;
currentPointY = nextPointY;
}
prepareLinePaint(linePaint);
int valueIndex = 0;
for (PointValue pointValue : linePaint.getValues()) {
final float rawX = computator.computeRawX(pointValue.getX());
final float rawY = computator.computeRawY(pointValue.getY());
if (valueIndex == 0) {
path.moveTo(rawX, rawY);
} else {
path.lineTo(rawX, rawY);
}
++valueIndex;
}
path.drawPath(path, linePaint);
if (linePaint.isFilled()) {
drawArea(path, linePaint);
}
path.reset();
if (line.isFilled()) {
drawArea(canvas, line);
}
path.reset();
} | private void drawSmoothPath(Canvas canvas, final Line line) {
linePaint.setStrokeWidth(ChartUtils.dp2px(density, line.getStrokeWidth()));
linePaint.setColor(line.getColor());
linePaint.setPathEffect(line.getPathEffect());
final int lineSize = line.getValues().size();
float prePreviousPointX = Float.NaN;
float prePreviousPointY = Float.NaN;
float previousPointX = Float.NaN;
float previousPointY = Float.NaN;
float currentPointX = Float.NaN;
float currentPointY = Float.NaN;
float nextPointX = Float.NaN;
float nextPointY = Float.NaN;
for (int valueIndex = 0; valueIndex < lineSize; ++valueIndex) {
if (Float.isNaN(currentPointX)) {
PointValue linePoint = line.getValues().get(valueIndex);
currentPointX = computator.computeRawX(linePoint.getX());
currentPointY = computator.computeRawY(linePoint.getY());
}
if (Float.isNaN(previousPointX)) {
if (valueIndex > 0) {
PointValue linePoint = line.getValues().get(valueIndex - 1);
previousPointX = computator.computeRawX(linePoint.getX());
previousPointY = computator.computeRawY(linePoint.getY());
} else {
previousPointX = currentPointX;
previousPointY = currentPointY;
}
}
if (Float.isNaN(prePreviousPointX)) {
if (valueIndex > 1) {
PointValue linePoint = line.getValues().get(valueIndex - 2);
prePreviousPointX = computator.computeRawX(linePoint.getX());
prePreviousPointY = computator.computeRawY(linePoint.getY());
} else {
prePreviousPointX = previousPointX;
prePreviousPointY = previousPointY;
}
}
if (valueIndex < lineSize - 1) {
PointValue linePoint = line.getValues().get(valueIndex + 1);
nextPointX = computator.computeRawX(linePoint.getX());
nextPointY = computator.computeRawY(linePoint.getY());
} else {
nextPointX = currentPointX;
nextPointY = currentPointY;
}
if (valueIndex == 0) {
path.moveTo(currentPointX, currentPointY);
} else {
final float firstDiffX = (currentPointX - prePreviousPointX);
final float firstDiffY = (currentPointY - prePreviousPointY);
final float secondDiffX = (nextPointX - previousPointX);
final float secondDiffY = (nextPointY - previousPointY);
final float firstControlPointX = previousPointX + (LINE_SMOOTHNESS * firstDiffX);
final float firstControlPointY = previousPointY + (LINE_SMOOTHNESS * firstDiffY);
final float secondControlPointX = currentPointX - (LINE_SMOOTHNESS * secondDiffX);
final float secondControlPointY = currentPointY - (LINE_SMOOTHNESS * secondDiffY);
path.cubicTo(firstControlPointX, firstControlPointY, secondControlPointX, secondControlPointY, currentPointX, currentPointY);
}
prePreviousPointX = previousPointX;
prePreviousPointY = previousPointY;
previousPointX = currentPointX;
previousPointY = currentPointY;
currentPointX = nextPointX;
currentPointY = nextPointY;
}
<DeepExtract>
prepareLinePaint(linePaint);
int valueIndex = 0;
for (PointValue pointValue : linePaint.getValues()) {
final float rawX = computator.computeRawX(pointValue.getX());
final float rawY = computator.computeRawY(pointValue.getY());
if (valueIndex == 0) {
path.moveTo(rawX, rawY);
} else {
path.lineTo(rawX, rawY);
}
++valueIndex;
}
path.drawPath(path, linePaint);
if (linePaint.isFilled()) {
drawArea(path, linePaint);
}
path.reset();
</DeepExtract>
if (line.isFilled()) {
drawArea(canvas, line);
}
path.reset();
} | hellocharts-android | positive | 473 |
@Override
public Vector scale(float scale) {
return mul(scale, this);
return this;
} | @Override
public Vector scale(float scale) {
<DeepExtract>
return mul(scale, this);
</DeepExtract>
return this;
} | Ents | positive | 474 |
public GitIntentBuilder tag(String tagName) {
intent.putStringArrayListExtra("tag", tagName);
return this;
} | public GitIntentBuilder tag(String tagName) {
<DeepExtract>
intent.putStringArrayListExtra("tag", tagName);
return this;
</DeepExtract>
} | agit | positive | 475 |
@Override
public void setContentView(int layoutResID) {
super.setContentView(layoutResID);
if (findViewById(getToolbarActionbarId()) != null) {
titleView = findViewById(getToolbarActionbarId()).findViewById(getToolbarTitleId());
setTitle(getTitle());
setSupportActionBar(findViewById(getToolbarActionbarId()));
}
} | @Override
public void setContentView(int layoutResID) {
super.setContentView(layoutResID);
<DeepExtract>
if (findViewById(getToolbarActionbarId()) != null) {
titleView = findViewById(getToolbarActionbarId()).findViewById(getToolbarTitleId());
setTitle(getTitle());
setSupportActionBar(findViewById(getToolbarActionbarId()));
}
</DeepExtract>
} | bible | positive | 476 |
private void addFeatureToSite(Map<String, Site> sites, String origin, int feature) {
Site site = null;
if (sites.containsKey(origin)) {
site = (Site) sites.get(origin);
} else {
site = new Site(origin);
sites.put(origin, site);
}
mFeatures |= (1 << feature);
} | private void addFeatureToSite(Map<String, Site> sites, String origin, int feature) {
Site site = null;
if (sites.containsKey(origin)) {
site = (Site) sites.get(origin);
} else {
site = new Site(origin);
sites.put(origin, site);
}
<DeepExtract>
mFeatures |= (1 << feature);
</DeepExtract>
} | TintBrowser | positive | 477 |
@Test
public void buySellStockTwice2() {
prices = Arrays.asList(100, 200);
maxProfit = 100;
assertEquals(maxProfit, BuySellStockTwice.buySellStockTwice(prices));
} | @Test
public void buySellStockTwice2() {
prices = Arrays.asList(100, 200);
maxProfit = 100;
<DeepExtract>
assertEquals(maxProfit, BuySellStockTwice.buySellStockTwice(prices));
</DeepExtract>
} | elements-of-programming-interviews-solutions | positive | 479 |
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
activity.setRequestedOrientation(globalSettings.getScreenOrientation());
} | @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
<DeepExtract>
activity.setRequestedOrientation(globalSettings.getScreenOrientation());
</DeepExtract>
} | homerplayer | positive | 481 |
public Criteria andBookPriceIn(List<Double> values) {
if (values == null) {
throw new RuntimeException("Value for " + "bookPrice" + " cannot be null");
}
criteria.add(new Criterion("book_price in", values));
return (Criteria) this;
} | public Criteria andBookPriceIn(List<Double> values) {
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "bookPrice" + " cannot be null");
}
criteria.add(new Criterion("book_price in", values));
</DeepExtract>
return (Criteria) this;
} | library_manager_system | positive | 482 |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.animated_logo_fragment, container, false);
mSubtitleView = mRootView.findViewById(R.id.logo_subtitle);
mLogoView = (AnimatedMuzeiLogoView) mRootView.findViewById(R.id.animated_logo);
mLogoView.setOnStateChangeListener(new AnimatedMuzeiLogoView.OnStateChangeListener() {
@Override
public void onStateChange(int state) {
if (state == AnimatedMuzeiLogoView.STATE_FILL_STARTED) {
mSubtitleView.setAlpha(0);
mSubtitleView.setVisibility(View.VISIBLE);
mSubtitleView.setTranslationY(-mSubtitleView.getHeight());
AnimatorSet set = new AnimatorSet();
Interpolator interpolator = new OvershootInterpolator();
ObjectAnimator a1 = ObjectAnimator.ofFloat(mLogoView, View.TRANSLATION_Y, 0);
ObjectAnimator a2 = ObjectAnimator.ofFloat(mSubtitleView, View.TRANSLATION_Y, 0);
ObjectAnimator a3 = ObjectAnimator.ofFloat(mSubtitleView, View.ALPHA, 1);
a1.setInterpolator(interpolator);
a2.setInterpolator(interpolator);
set.setDuration(500).playTogether(a1, a2, a3);
set.start();
if (mOnFillStartedCallback != null) {
mOnFillStartedCallback.run();
}
}
}
});
mLogoView.reset();
mLogoView.setTranslationY(mInitialLogoOffset);
mSubtitleView.setVisibility(View.INVISIBLE);
return mRootView;
} | @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.animated_logo_fragment, container, false);
mSubtitleView = mRootView.findViewById(R.id.logo_subtitle);
mLogoView = (AnimatedMuzeiLogoView) mRootView.findViewById(R.id.animated_logo);
mLogoView.setOnStateChangeListener(new AnimatedMuzeiLogoView.OnStateChangeListener() {
@Override
public void onStateChange(int state) {
if (state == AnimatedMuzeiLogoView.STATE_FILL_STARTED) {
mSubtitleView.setAlpha(0);
mSubtitleView.setVisibility(View.VISIBLE);
mSubtitleView.setTranslationY(-mSubtitleView.getHeight());
AnimatorSet set = new AnimatorSet();
Interpolator interpolator = new OvershootInterpolator();
ObjectAnimator a1 = ObjectAnimator.ofFloat(mLogoView, View.TRANSLATION_Y, 0);
ObjectAnimator a2 = ObjectAnimator.ofFloat(mSubtitleView, View.TRANSLATION_Y, 0);
ObjectAnimator a3 = ObjectAnimator.ofFloat(mSubtitleView, View.ALPHA, 1);
a1.setInterpolator(interpolator);
a2.setInterpolator(interpolator);
set.setDuration(500).playTogether(a1, a2, a3);
set.start();
if (mOnFillStartedCallback != null) {
mOnFillStartedCallback.run();
}
}
}
});
<DeepExtract>
mLogoView.reset();
mLogoView.setTranslationY(mInitialLogoOffset);
mSubtitleView.setVisibility(View.INVISIBLE);
</DeepExtract>
return mRootView;
} | ScreenLocker | positive | 483 |
@Override
public void onSuccess(Object result) {
if (Storage.isSupported() && rememberme.getValue() == true) {
Storage localStorage = Storage.getLocalStorage();
localStorage.setItem("username", usernameText.getValue());
localStorage.setItem("password", passwordText.getValue());
}
handler.handleLogin(true);
hide();
} | @Override
public void onSuccess(Object result) {
if (Storage.isSupported() && rememberme.getValue() == true) {
Storage localStorage = Storage.getLocalStorage();
localStorage.setItem("username", usernameText.getValue());
localStorage.setItem("password", passwordText.getValue());
}
<DeepExtract>
handler.handleLogin(true);
hide();
</DeepExtract>
} | osw-web | positive | 484 |
@Override
public void onResume() {
super.onResume();
CrimeLab crimeLab = CrimeLab.get(getActivity());
List<Crime> crimes = crimeLab.getCrimes();
if (mAdapter == null) {
mAdapter = new CrimeAdapter(crimes);
mCrimeRecyclerView.setAdapter(mAdapter);
} else {
mAdapter.notifyDataSetChanged();
}
} | @Override
public void onResume() {
super.onResume();
<DeepExtract>
CrimeLab crimeLab = CrimeLab.get(getActivity());
List<Crime> crimes = crimeLab.getCrimes();
if (mAdapter == null) {
mAdapter = new CrimeAdapter(crimes);
mCrimeRecyclerView.setAdapter(mAdapter);
} else {
mAdapter.notifyDataSetChanged();
}
</DeepExtract>
} | AndroidBNR2 | positive | 485 |
static Mode mapIntToValue(final int modeInt) {
for (Mode value : Mode.values()) {
if (modeInt == value.getIntValue()) {
return value;
}
}
return ROTATE;
} | static Mode mapIntToValue(final int modeInt) {
for (Mode value : Mode.values()) {
if (modeInt == value.getIntValue()) {
return value;
}
}
<DeepExtract>
return ROTATE;
</DeepExtract>
} | My-Weather | positive | 486 |
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (null == data || 0 == data.size()) {
return;
}
canvas.drawRect(0, mItemHeight * mHalfItemCount, viewWidth, mItemHeight * (mHalfItemCount + 1), mSelectedBgPaint);
String text;
float midY;
int startShowIndex = Math.max(0, mSelectedIndex - (mHalfItemCount + 1));
int endShowIndex = Math.min(data.size() - 1, mSelectedIndex + (mHalfItemCount + 1));
for (int i = startShowIndex; i <= endShowIndex; i++) {
text = data.get(i);
if (i == mSelectedIndex) {
mTextPaint.setColor(mSelectTxtColor);
} else {
mTextPaint.setColor(mNormalTxtColor);
}
midY = mItemHeight * (mHalfItemCount - (mSelectedIndex - i)) + mItemHeight / 2 - scrollY;
setTextPaint(mTextPaint, midY);
canvas.drawText(text, (viewWidth - mTextPaint.measureText(text)) / 2, midY + getTextBaselineToCenter(mTextPaint), mTextPaint);
}
} | @Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (null == data || 0 == data.size()) {
return;
}
canvas.drawRect(0, mItemHeight * mHalfItemCount, viewWidth, mItemHeight * (mHalfItemCount + 1), mSelectedBgPaint);
<DeepExtract>
String text;
float midY;
int startShowIndex = Math.max(0, mSelectedIndex - (mHalfItemCount + 1));
int endShowIndex = Math.min(data.size() - 1, mSelectedIndex + (mHalfItemCount + 1));
for (int i = startShowIndex; i <= endShowIndex; i++) {
text = data.get(i);
if (i == mSelectedIndex) {
mTextPaint.setColor(mSelectTxtColor);
} else {
mTextPaint.setColor(mNormalTxtColor);
}
midY = mItemHeight * (mHalfItemCount - (mSelectedIndex - i)) + mItemHeight / 2 - scrollY;
setTextPaint(mTextPaint, midY);
canvas.drawText(text, (viewWidth - mTextPaint.measureText(text)) / 2, midY + getTextBaselineToCenter(mTextPaint), mTextPaint);
}
</DeepExtract>
} | ZJYWidget | positive | 487 |
@Test(expected = IllegalArgumentException.class)
public void testBadContainerSuperPoint() throws NoSuchMethodException {
BadContainerSuperPoint bad = new BadContainerSuperPoint();
return x;
} | @Test(expected = IllegalArgumentException.class)
public void testBadContainerSuperPoint() throws NoSuchMethodException {
BadContainerSuperPoint bad = new BadContainerSuperPoint();
<DeepExtract>
return x;
</DeepExtract>
} | ObjectLayout | positive | 488 |
@Override
public void onDragMove(DragEvent e) {
double currX;
if (_hasTextBox) {
currX = FxUtil.getStyleLeft(this);
} else {
currX = FxUtil.getTranslateX(el());
}
if (currX > 0) {
if (e.OffsetX > 0) {
currX += (int) (e.OffsetX / 2);
} else {
currX += e.OffsetX * 2;
}
} else if (-currX + panelWidth > widgetWidth) {
if (e.OffsetX < 0) {
currX += (int) (e.OffsetX / 2);
} else {
currX += e.OffsetX * 2;
}
} else {
currX += e.OffsetX;
}
if (_hasTextBox) {
FxUtil.setStyleLeft(this, currX);
} else {
FxUtil.setTranslateX(el(), currX);
}
} | @Override
public void onDragMove(DragEvent e) {
double currX;
if (_hasTextBox) {
currX = FxUtil.getStyleLeft(this);
} else {
currX = FxUtil.getTranslateX(el());
}
if (currX > 0) {
if (e.OffsetX > 0) {
currX += (int) (e.OffsetX / 2);
} else {
currX += e.OffsetX * 2;
}
} else if (-currX + panelWidth > widgetWidth) {
if (e.OffsetX < 0) {
currX += (int) (e.OffsetX / 2);
} else {
currX += e.OffsetX * 2;
}
} else {
currX += e.OffsetX;
}
<DeepExtract>
if (_hasTextBox) {
FxUtil.setStyleLeft(this, currX);
} else {
FxUtil.setTranslateX(el(), currX);
}
</DeepExtract>
} | next | positive | 489 |
public PointF mapImageToView(PointF imagePoint) {
float[] points = mTempValues;
points[0] = imagePoint.x;
points[1] = imagePoint.y;
for (int i = 0; i < 1; i++) {
points[i * 2 + 0] = points[i * 2 + 0] * mImageBounds.width() + mImageBounds.left;
points[i * 2 + 1] = points[i * 2 + 1] * mImageBounds.height() + mImageBounds.top;
}
mActiveTransform.mapPoints(points, 0, points, 0, 1);
return new PointF(points[0], points[1]);
} | public PointF mapImageToView(PointF imagePoint) {
float[] points = mTempValues;
points[0] = imagePoint.x;
points[1] = imagePoint.y;
<DeepExtract>
for (int i = 0; i < 1; i++) {
points[i * 2 + 0] = points[i * 2 + 0] * mImageBounds.width() + mImageBounds.left;
points[i * 2 + 1] = points[i * 2 + 1] * mImageBounds.height() + mImageBounds.top;
}
</DeepExtract>
mActiveTransform.mapPoints(points, 0, points, 0, 1);
return new PointF(points[0], points[1]);
} | MyDiary | positive | 490 |
@Override
public int enable(Socket socket) {
int result = -1;
if (pollable(socket) != null) {
if (pollable(socket).getChannel() != null) {
result = poller.register(pollable(socket).getChannel(), sumOptions(pollable(socket)));
} else {
result = poller.register(pollable(socket).getSocket().getZMQSocket(), sumOptions(pollable(socket)));
}
}
return result;
} | @Override
public int enable(Socket socket) {
<DeepExtract>
int result = -1;
if (pollable(socket) != null) {
if (pollable(socket).getChannel() != null) {
result = poller.register(pollable(socket).getChannel(), sumOptions(pollable(socket)));
} else {
result = poller.register(pollable(socket).getSocket().getZMQSocket(), sumOptions(pollable(socket)));
}
}
return result;
</DeepExtract>
} | jzmq-api | positive | 491 |
public E removeFirst() {
E x;
final ReentrantLock lock = this.lock;
lock.lock();
try {
x = unlinkFirst();
} finally {
lock.unlock();
}
if (x == null)
throw new NoSuchElementException();
return x;
} | public E removeFirst() {
<DeepExtract>
E x;
final ReentrantLock lock = this.lock;
lock.lock();
try {
x = unlinkFirst();
} finally {
lock.unlock();
}
</DeepExtract>
if (x == null)
throw new NoSuchElementException();
return x;
} | Android-Universal-Image-Loader | positive | 493 |
public void startServer(IConfig config, List<? extends InterceptHandler> handlers, ISslContextCreator sslCtxCreator, IAuthenticator authenticator, IAuthorizator authorizator) throws IOException {
if (handlers == null) {
handlers = Collections.emptyList();
}
LOG.info("Starting Moquette Server. MQTT message interceptors={}", getInterceptorIds(handlers));
scheduler = Executors.newScheduledThreadPool(1);
final String handlerProp = System.getProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME);
if (handlerProp != null) {
config.setProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME, handlerProp);
}
LOG.info("Configuring embedded Hazelcast instance");
String interceptHandlerClassname = config.getProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME);
if (interceptHandlerClassname == null || !HZ_INTERCEPT_HANDLER.equals(interceptHandlerClassname)) {
LOG.info("There are no Hazelcast intercept handlers. The server won't start a Hazelcast instance.");
return;
}
String hzConfigPath = config.getProperty(BrokerConstants.HAZELCAST_CONFIGURATION);
if (hzConfigPath != null) {
boolean isHzConfigOnClasspath = this.getClass().getClassLoader().getResource(hzConfigPath) != null;
Config hzconfig = isHzConfigOnClasspath ? new ClasspathXmlConfig(hzConfigPath) : new FileSystemXmlConfig(hzConfigPath);
LOG.info("Starting Hazelcast instance. ConfigurationFile={}", hzconfig);
hazelcastInstance = Hazelcast.newHazelcastInstance(hzconfig);
} else {
LOG.info("Starting Hazelcast instance with default configuration");
hazelcastInstance = Hazelcast.newHazelcastInstance();
}
listenOnHazelCastMsg();
final String persistencePath = config.getProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME);
LOG.info("Configuring Using persistent store file, path={}", persistencePath);
m_processorBootstrapper = new ProtocolProcessorBootstrapper();
final ProtocolProcessor processor = m_processorBootstrapper.init(config, handlers, authenticator, authorizator, this);
LOG.info("Initialized MQTT protocol processor");
if (sslCtxCreator == null) {
LOG.warn("Using default SSL context creator");
sslCtxCreator = new DefaultMoquetteSslContextCreator(config);
}
LOG.info("Binding server to the configured ports");
m_acceptor = new NettyAcceptor();
m_acceptor.initialize(processor, config, sslCtxCreator);
m_processor = processor;
LOG.info("Moquette server has been initialized successfully");
m_initialized = true;
} | public void startServer(IConfig config, List<? extends InterceptHandler> handlers, ISslContextCreator sslCtxCreator, IAuthenticator authenticator, IAuthorizator authorizator) throws IOException {
if (handlers == null) {
handlers = Collections.emptyList();
}
LOG.info("Starting Moquette Server. MQTT message interceptors={}", getInterceptorIds(handlers));
scheduler = Executors.newScheduledThreadPool(1);
final String handlerProp = System.getProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME);
if (handlerProp != null) {
config.setProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME, handlerProp);
}
<DeepExtract>
LOG.info("Configuring embedded Hazelcast instance");
String interceptHandlerClassname = config.getProperty(BrokerConstants.INTERCEPT_HANDLER_PROPERTY_NAME);
if (interceptHandlerClassname == null || !HZ_INTERCEPT_HANDLER.equals(interceptHandlerClassname)) {
LOG.info("There are no Hazelcast intercept handlers. The server won't start a Hazelcast instance.");
return;
}
String hzConfigPath = config.getProperty(BrokerConstants.HAZELCAST_CONFIGURATION);
if (hzConfigPath != null) {
boolean isHzConfigOnClasspath = this.getClass().getClassLoader().getResource(hzConfigPath) != null;
Config hzconfig = isHzConfigOnClasspath ? new ClasspathXmlConfig(hzConfigPath) : new FileSystemXmlConfig(hzConfigPath);
LOG.info("Starting Hazelcast instance. ConfigurationFile={}", hzconfig);
hazelcastInstance = Hazelcast.newHazelcastInstance(hzconfig);
} else {
LOG.info("Starting Hazelcast instance with default configuration");
hazelcastInstance = Hazelcast.newHazelcastInstance();
}
listenOnHazelCastMsg();
</DeepExtract>
final String persistencePath = config.getProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME);
LOG.info("Configuring Using persistent store file, path={}", persistencePath);
m_processorBootstrapper = new ProtocolProcessorBootstrapper();
final ProtocolProcessor processor = m_processorBootstrapper.init(config, handlers, authenticator, authorizator, this);
LOG.info("Initialized MQTT protocol processor");
if (sslCtxCreator == null) {
LOG.warn("Using default SSL context creator");
sslCtxCreator = new DefaultMoquetteSslContextCreator(config);
}
LOG.info("Binding server to the configured ports");
m_acceptor = new NettyAcceptor();
m_acceptor.initialize(processor, config, sslCtxCreator);
m_processor = processor;
LOG.info("Moquette server has been initialized successfully");
m_initialized = true;
} | springboot-mqtt | positive | 494 |
public static boolean expression(PsiBuilder b, int l, int g) {
if (!recursion_guard_(b, l, "expression"))
return false;
addVariant(b, "<expression>");
Marker m = enter_section_(b, l, _NONE_, "<expression>");
if (!recursion_guard_(b, l + 1, "unaryExpression"))
r = false;
boolean r, p;
Marker m = enter_section_(b, l + 1, _COLLAPSE_, UNARY_EXPRESSION, "<unary expression>");
r = unaryOperator(b, l + 1 + 1);
p = r;
r = r && expression(b, l + 1 + 1, -1);
exit_section_(b, l + 1, m, r, p, null);
return r || p;
if (!r)
r = parenthesizedExpression(b, l + 1);
if (!r)
r = indexedExpression(b, l + 1);
if (!r)
r = referenceExpression(b, l + 1);
if (!r)
r = variableExpression(b, l + 1);
if (!r)
r = literalExpression(b, l + 1);
p = r;
r = r && expression_0(b, l + 1, g);
exit_section_(b, l, m, null, r, p, null);
return r || p;
} | public static boolean expression(PsiBuilder b, int l, int g) {
if (!recursion_guard_(b, l, "expression"))
return false;
addVariant(b, "<expression>");
Marker m = enter_section_(b, l, _NONE_, "<expression>");
<DeepExtract>
if (!recursion_guard_(b, l + 1, "unaryExpression"))
r = false;
boolean r, p;
Marker m = enter_section_(b, l + 1, _COLLAPSE_, UNARY_EXPRESSION, "<unary expression>");
r = unaryOperator(b, l + 1 + 1);
p = r;
r = r && expression(b, l + 1 + 1, -1);
exit_section_(b, l + 1, m, r, p, null);
return r || p;
</DeepExtract>
if (!r)
r = parenthesizedExpression(b, l + 1);
if (!r)
r = indexedExpression(b, l + 1);
if (!r)
r = referenceExpression(b, l + 1);
if (!r)
r = variableExpression(b, l + 1);
if (!r)
r = literalExpression(b, l + 1);
p = r;
r = r && expression_0(b, l + 1, g);
exit_section_(b, l, m, null, r, p, null);
return r || p;
} | Cofe-Mybatis | positive | 495 |
@Override
public void clicked(InputEvent event, float x, float y) {
if (this.getSelectedBlock() != null && this.currentScreen == this.hud) {
IChunk chunk = world.getChunk(selectedBlock);
if (chunk != null) {
try {
Block block = chunk.getBlock(selectedBlock.x & (world.getChunkSize() - 1), selectedBlock.y, selectedBlock.z & (world.getChunkSize() - 1));
if (block != null && block.isSelectable()) {
if (this.isRemote()) {
mcClientConn.getClient().getSession().send(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND));
mcClientConn.getClient().getSession().send(new ClientPlayerActionPacket(PlayerAction.FINISH_DIGGING, new Position(selectedBlock.x, selectedBlock.y, selectedBlock.z), BlockFace.UP));
} else {
this.getWorld().removeBlock(this.getSelectedBlock().x, this.getSelectedBlock().y, this.getSelectedBlock().z);
}
updateSelectedBlock();
}
} catch (CoordinatesOutOfBoundsException ex) {
ex.printStackTrace();
}
}
}
} | @Override
public void clicked(InputEvent event, float x, float y) {
<DeepExtract>
if (this.getSelectedBlock() != null && this.currentScreen == this.hud) {
IChunk chunk = world.getChunk(selectedBlock);
if (chunk != null) {
try {
Block block = chunk.getBlock(selectedBlock.x & (world.getChunkSize() - 1), selectedBlock.y, selectedBlock.z & (world.getChunkSize() - 1));
if (block != null && block.isSelectable()) {
if (this.isRemote()) {
mcClientConn.getClient().getSession().send(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND));
mcClientConn.getClient().getSession().send(new ClientPlayerActionPacket(PlayerAction.FINISH_DIGGING, new Position(selectedBlock.x, selectedBlock.y, selectedBlock.z), BlockFace.UP));
} else {
this.getWorld().removeBlock(this.getSelectedBlock().x, this.getSelectedBlock().y, this.getSelectedBlock().z);
}
updateSelectedBlock();
}
} catch (CoordinatesOutOfBoundsException ex) {
ex.printStackTrace();
}
}
}
</DeepExtract>
} | Radix | positive | 496 |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
Completable completable = Completable.fromAction(() -> {
log("Let's do something");
});
completable.subscribe(() -> {
log("Finished");
}, throwable -> {
log(throwable);
});
Single.just("One item").subscribe((item) -> {
log(item);
}, (throwable) -> {
log(throwable);
});
Maybe.empty();
Maybe.just("Item").subscribe(s -> {
log("On Success: " + s);
});
Maybe.just("Item").subscribe(s -> {
log("On Success: " + s);
}, throwable -> log("error"));
Maybe.just("Item").subscribe(s -> log("success: " + s), throwable -> log("error"), () -> log("onComplete"));
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
stockDataAdapter = new StockDataAdapter();
recyclerView.setAdapter(stockDataAdapter);
Observable.just("Please use this app responsibly!").subscribe(s -> helloText.setText(s));
Observable.just(new StockUpdate("GOOGLE", 12.43, new Date()), new StockUpdate("APPL", 645.1, new Date()), new StockUpdate("TWTR", 1.43, new Date())).subscribe(stockUpdate -> {
Log.d("APP", "New update " + stockUpdate.getStockSymbol());
stockDataAdapter.add(stockUpdate);
});
} | @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
<DeepExtract>
Completable completable = Completable.fromAction(() -> {
log("Let's do something");
});
completable.subscribe(() -> {
log("Finished");
}, throwable -> {
log(throwable);
});
Single.just("One item").subscribe((item) -> {
log(item);
}, (throwable) -> {
log(throwable);
});
Maybe.empty();
Maybe.just("Item").subscribe(s -> {
log("On Success: " + s);
});
Maybe.just("Item").subscribe(s -> {
log("On Success: " + s);
}, throwable -> log("error"));
Maybe.just("Item").subscribe(s -> log("success: " + s), throwable -> log("error"), () -> log("onComplete"));
</DeepExtract>
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
stockDataAdapter = new StockDataAdapter();
recyclerView.setAdapter(stockDataAdapter);
Observable.just("Please use this app responsibly!").subscribe(s -> helloText.setText(s));
Observable.just(new StockUpdate("GOOGLE", 12.43, new Date()), new StockUpdate("APPL", 645.1, new Date()), new StockUpdate("TWTR", 1.43, new Date())).subscribe(stockUpdate -> {
Log.d("APP", "New update " + stockUpdate.getStockSymbol());
stockDataAdapter.add(stockUpdate);
});
} | Reactive-Android-Programming | positive | 497 |
public URL getVersionsPropertiesUrl() {
String name = versionsPropertiesUrl.getName();
T tValue = versionsPropertiesUrl.getValue();
Class<T> type = versionsPropertiesUrl.getType();
return resolver(name, tValue, type);
} | public URL getVersionsPropertiesUrl() {
<DeepExtract>
String name = versionsPropertiesUrl.getName();
T tValue = versionsPropertiesUrl.getValue();
Class<T> type = versionsPropertiesUrl.getType();
return resolver(name, tValue, type);
</DeepExtract>
} | webdrivermanager | positive | 498 |
public Criteria andPasswordLessThan(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "password" + " cannot be null");
}
criteria.add(new Criterion("password <", value));
return (Criteria) this;
} | public Criteria andPasswordLessThan(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "password" + " cannot be null");
}
criteria.add(new Criterion("password <", value));
</DeepExtract>
return (Criteria) this;
} | PetStore | positive | 499 |
private void uploadFile(String coverPath, String filePath) {
if (loadingDialog == null) {
loadingDialog = new LoadingDialog(getContext());
loadingDialog.setLoadingText(getString(R.string.upload_text));
loadingDialog.setCanceledOnTouchOutside(false);
loadingDialog.setCancelable(false);
}
if (!loadingDialog.isShowing()) {
loadingDialog.show();
}
AtomicInteger count = new AtomicInteger(1);
if (!TextUtils.isEmpty(coverPath)) {
count.set(2);
ArchTaskExecutor.getIOThreadExecutor().execute(new Runnable() {
@Override
public void run() {
int remain = count.decrementAndGet();
coverUrl = FileUploadManager.upload(coverPath);
if (remain <= 0) {
if (!TextUtils.isEmpty(fileUrl) && !TextUtils.isEmpty(coverUrl)) {
publish();
} else {
dismissLoadingDialog();
showToast(getString(R.string.file_upload_failed));
}
}
}
});
}
ArchTaskExecutor.getIOThreadExecutor().execute(new Runnable() {
@Override
public void run() {
int remain = count.decrementAndGet();
fileUrl = FileUploadManager.upload(filePath);
if (remain <= 0) {
if (!TextUtils.isEmpty(fileUrl) || !TextUtils.isEmpty(coverPath) && !TextUtils.isEmpty(coverUrl)) {
publish();
} else {
dismissLoadingDialog();
showToast(getString(R.string.file_upload_failed));
}
}
}
});
} | private void uploadFile(String coverPath, String filePath) {
<DeepExtract>
if (loadingDialog == null) {
loadingDialog = new LoadingDialog(getContext());
loadingDialog.setLoadingText(getString(R.string.upload_text));
loadingDialog.setCanceledOnTouchOutside(false);
loadingDialog.setCancelable(false);
}
if (!loadingDialog.isShowing()) {
loadingDialog.show();
}
</DeepExtract>
AtomicInteger count = new AtomicInteger(1);
if (!TextUtils.isEmpty(coverPath)) {
count.set(2);
ArchTaskExecutor.getIOThreadExecutor().execute(new Runnable() {
@Override
public void run() {
int remain = count.decrementAndGet();
coverUrl = FileUploadManager.upload(coverPath);
if (remain <= 0) {
if (!TextUtils.isEmpty(fileUrl) && !TextUtils.isEmpty(coverUrl)) {
publish();
} else {
dismissLoadingDialog();
showToast(getString(R.string.file_upload_failed));
}
}
}
});
}
ArchTaskExecutor.getIOThreadExecutor().execute(new Runnable() {
@Override
public void run() {
int remain = count.decrementAndGet();
fileUrl = FileUploadManager.upload(filePath);
if (remain <= 0) {
if (!TextUtils.isEmpty(fileUrl) || !TextUtils.isEmpty(coverPath) && !TextUtils.isEmpty(coverUrl)) {
publish();
} else {
dismissLoadingDialog();
showToast(getString(R.string.file_upload_failed));
}
}
}
});
} | JokeVideo | positive | 500 |
@Test
public void thenIActionR_doesNothingThenReturnsValue() throws Throwable {
v(tag, "Start " + Thread.currentThread().getStackTrace()[0].getMethodName());
Integer expected = 66;
IAltFuture<?, Integer> test = threadType.then(() -> {
v(tag, "Do 66");
return expected;
}).then(() -> v(tag, "After 66")).then(() -> v(tag, "1")).then(() -> v(tag, "2")).then(() -> v(tag, "3")).then(() -> v(tag, "After notify 66")).fork();
v(tag, "Wait for 66");
return new AltFutureFuture<>(test).get(TEST_TIMEOUT, TimeUnit.MILLISECONDS);
v(tag, "Notified 66");
assertThat(expected).isEqualTo(test.get());
} | @Test
public void thenIActionR_doesNothingThenReturnsValue() throws Throwable {
v(tag, "Start " + Thread.currentThread().getStackTrace()[0].getMethodName());
Integer expected = 66;
IAltFuture<?, Integer> test = threadType.then(() -> {
v(tag, "Do 66");
return expected;
}).then(() -> v(tag, "After 66")).then(() -> v(tag, "1")).then(() -> v(tag, "2")).then(() -> v(tag, "3")).then(() -> v(tag, "After notify 66")).fork();
v(tag, "Wait for 66");
<DeepExtract>
return new AltFutureFuture<>(test).get(TEST_TIMEOUT, TimeUnit.MILLISECONDS);
</DeepExtract>
v(tag, "Notified 66");
assertThat(expected).isEqualTo(test.get());
} | cascade | positive | 502 |
private short computeDigitalSignature(APDU apdu) {
if (!(pw1.isValidated() && pw1_modes[PW1_MODE_NO81]))
ISOException.throwIt(SW_SECURITY_STATUS_NOT_SATISFIED);
if (pw1_status == (byte) 0x00)
pw1_modes[PW1_MODE_NO81] = false;
if (!sig_key.getPrivate().isInitialized())
ISOException.throwIt(SW_REFERENCED_DATA_NOT_FOUND);
cipher.init(sig_key.getPrivate(), Cipher.MODE_ENCRYPT);
for (short i = (short) (ds_counter.length - 1); i >= 0; i--) {
if ((short) (ds_counter[i] & 0xFF) >= 0xFF) {
if (i == 0) {
ISOException.throwIt(SW_WARNING_STATE_UNCHANGED);
} else {
ds_counter[i] = 0;
}
} else {
ds_counter[i]++;
break;
}
}
short length = cipher.doFinal(buffer, _0, in_received, buffer, in_received);
Util.arrayCopyNonAtomic(buffer, in_received, buffer, _0, length);
return length;
} | private short computeDigitalSignature(APDU apdu) {
if (!(pw1.isValidated() && pw1_modes[PW1_MODE_NO81]))
ISOException.throwIt(SW_SECURITY_STATUS_NOT_SATISFIED);
if (pw1_status == (byte) 0x00)
pw1_modes[PW1_MODE_NO81] = false;
if (!sig_key.getPrivate().isInitialized())
ISOException.throwIt(SW_REFERENCED_DATA_NOT_FOUND);
cipher.init(sig_key.getPrivate(), Cipher.MODE_ENCRYPT);
<DeepExtract>
for (short i = (short) (ds_counter.length - 1); i >= 0; i--) {
if ((short) (ds_counter[i] & 0xFF) >= 0xFF) {
if (i == 0) {
ISOException.throwIt(SW_WARNING_STATE_UNCHANGED);
} else {
ds_counter[i] = 0;
}
} else {
ds_counter[i]++;
break;
}
}
</DeepExtract>
short length = cipher.doFinal(buffer, _0, in_received, buffer, in_received);
Util.arrayCopyNonAtomic(buffer, in_received, buffer, _0, length);
return length;
} | AppletPlayground | positive | 503 |
@Test
public void test() {
assertEquals(CoverageRange.ABYSSMAL, CoverageRange.valueOf(-20.0));
assertNotNull(CoverageRange.fillColorOf(-20.0));
assertNotNull(CoverageRange.ABYSSMAL.getLineColor());
assertNotNull(CoverageRange.ABYSSMAL.getFillHexString());
assertNotNull(CoverageRange.ABYSSMAL.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.ABYSSMAL.getLineColor()));
assertTrue("Had " + -20.0 + " and floor " + CoverageRange.ABYSSMAL.getFloor(), -20.0 < 0 || -20.0 >= CoverageRange.ABYSSMAL.getFloor());
assertEquals(CoverageRange.ABYSSMAL, CoverageRange.valueOf(0.0));
assertNotNull(CoverageRange.fillColorOf(0.0));
assertNotNull(CoverageRange.ABYSSMAL.getLineColor());
assertNotNull(CoverageRange.ABYSSMAL.getFillHexString());
assertNotNull(CoverageRange.ABYSSMAL.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.ABYSSMAL.getLineColor()));
assertTrue("Had " + 0.0 + " and floor " + CoverageRange.ABYSSMAL.getFloor(), 0.0 < 0 || 0.0 >= CoverageRange.ABYSSMAL.getFloor());
assertEquals(CoverageRange.ABYSSMAL, CoverageRange.valueOf(10.3));
assertNotNull(CoverageRange.fillColorOf(10.3));
assertNotNull(CoverageRange.ABYSSMAL.getLineColor());
assertNotNull(CoverageRange.ABYSSMAL.getFillHexString());
assertNotNull(CoverageRange.ABYSSMAL.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.ABYSSMAL.getLineColor()));
assertTrue("Had " + 10.3 + " and floor " + CoverageRange.ABYSSMAL.getFloor(), 10.3 < 0 || 10.3 >= CoverageRange.ABYSSMAL.getFloor());
assertEquals(CoverageRange.TRAGIC, CoverageRange.valueOf(25.0));
assertNotNull(CoverageRange.fillColorOf(25.0));
assertNotNull(CoverageRange.TRAGIC.getLineColor());
assertNotNull(CoverageRange.TRAGIC.getFillHexString());
assertNotNull(CoverageRange.TRAGIC.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.TRAGIC.getLineColor()));
assertTrue("Had " + 25.0 + " and floor " + CoverageRange.TRAGIC.getFloor(), 25.0 < 0 || 25.0 >= CoverageRange.TRAGIC.getFloor());
assertEquals(CoverageRange.TRAGIC, CoverageRange.valueOf(32.0));
assertNotNull(CoverageRange.fillColorOf(32.0));
assertNotNull(CoverageRange.TRAGIC.getLineColor());
assertNotNull(CoverageRange.TRAGIC.getFillHexString());
assertNotNull(CoverageRange.TRAGIC.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.TRAGIC.getLineColor()));
assertTrue("Had " + 32.0 + " and floor " + CoverageRange.TRAGIC.getFloor(), 32.0 < 0 || 32.0 >= CoverageRange.TRAGIC.getFloor());
assertEquals(CoverageRange.POOR, CoverageRange.valueOf(50.0));
assertNotNull(CoverageRange.fillColorOf(50.0));
assertNotNull(CoverageRange.POOR.getLineColor());
assertNotNull(CoverageRange.POOR.getFillHexString());
assertNotNull(CoverageRange.POOR.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.POOR.getLineColor()));
assertTrue("Had " + 50.0 + " and floor " + CoverageRange.POOR.getFloor(), 50.0 < 0 || 50.0 >= CoverageRange.POOR.getFloor());
assertEquals(CoverageRange.POOR, CoverageRange.valueOf(68.2));
assertNotNull(CoverageRange.fillColorOf(68.2));
assertNotNull(CoverageRange.POOR.getLineColor());
assertNotNull(CoverageRange.POOR.getFillHexString());
assertNotNull(CoverageRange.POOR.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.POOR.getLineColor()));
assertTrue("Had " + 68.2 + " and floor " + CoverageRange.POOR.getFloor(), 68.2 < 0 || 68.2 >= CoverageRange.POOR.getFloor());
assertEquals(CoverageRange.FAIR, CoverageRange.valueOf(75.0));
assertNotNull(CoverageRange.fillColorOf(75.0));
assertNotNull(CoverageRange.FAIR.getLineColor());
assertNotNull(CoverageRange.FAIR.getFillHexString());
assertNotNull(CoverageRange.FAIR.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.FAIR.getLineColor()));
assertTrue("Had " + 75.0 + " and floor " + CoverageRange.FAIR.getFloor(), 75.0 < 0 || 75.0 >= CoverageRange.FAIR.getFloor());
assertEquals(CoverageRange.FAIR, CoverageRange.valueOf(83.0));
assertNotNull(CoverageRange.fillColorOf(83.0));
assertNotNull(CoverageRange.FAIR.getLineColor());
assertNotNull(CoverageRange.FAIR.getFillHexString());
assertNotNull(CoverageRange.FAIR.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.FAIR.getLineColor()));
assertTrue("Had " + 83.0 + " and floor " + CoverageRange.FAIR.getFloor(), 83.0 < 0 || 83.0 >= CoverageRange.FAIR.getFloor());
assertEquals(CoverageRange.SUFFICIENT, CoverageRange.valueOf(85.0));
assertNotNull(CoverageRange.fillColorOf(85.0));
assertNotNull(CoverageRange.SUFFICIENT.getLineColor());
assertNotNull(CoverageRange.SUFFICIENT.getFillHexString());
assertNotNull(CoverageRange.SUFFICIENT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.SUFFICIENT.getLineColor()));
assertTrue("Had " + 85.0 + " and floor " + CoverageRange.SUFFICIENT.getFloor(), 85.0 < 0 || 85.0 >= CoverageRange.SUFFICIENT.getFloor());
assertEquals(CoverageRange.SUFFICIENT, CoverageRange.valueOf(91.0));
assertNotNull(CoverageRange.fillColorOf(91.0));
assertNotNull(CoverageRange.SUFFICIENT.getLineColor());
assertNotNull(CoverageRange.SUFFICIENT.getFillHexString());
assertNotNull(CoverageRange.SUFFICIENT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.SUFFICIENT.getLineColor()));
assertTrue("Had " + 91.0 + " and floor " + CoverageRange.SUFFICIENT.getFloor(), 91.0 < 0 || 91.0 >= CoverageRange.SUFFICIENT.getFloor());
assertEquals(CoverageRange.GOOD, CoverageRange.valueOf(92.0));
assertNotNull(CoverageRange.fillColorOf(92.0));
assertNotNull(CoverageRange.GOOD.getLineColor());
assertNotNull(CoverageRange.GOOD.getFillHexString());
assertNotNull(CoverageRange.GOOD.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.GOOD.getLineColor()));
assertTrue("Had " + 92.0 + " and floor " + CoverageRange.GOOD.getFloor(), 92.0 < 0 || 92.0 >= CoverageRange.GOOD.getFloor());
assertEquals(CoverageRange.GOOD, CoverageRange.valueOf(96.999));
assertNotNull(CoverageRange.fillColorOf(96.999));
assertNotNull(CoverageRange.GOOD.getLineColor());
assertNotNull(CoverageRange.GOOD.getFillHexString());
assertNotNull(CoverageRange.GOOD.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.GOOD.getLineColor()));
assertTrue("Had " + 96.999 + " and floor " + CoverageRange.GOOD.getFloor(), 96.999 < 0 || 96.999 >= CoverageRange.GOOD.getFloor());
assertEquals(CoverageRange.EXCELLENT, CoverageRange.valueOf(97.0));
assertNotNull(CoverageRange.fillColorOf(97.0));
assertNotNull(CoverageRange.EXCELLENT.getLineColor());
assertNotNull(CoverageRange.EXCELLENT.getFillHexString());
assertNotNull(CoverageRange.EXCELLENT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.EXCELLENT.getLineColor()));
assertTrue("Had " + 97.0 + " and floor " + CoverageRange.EXCELLENT.getFloor(), 97.0 < 0 || 97.0 >= CoverageRange.EXCELLENT.getFloor());
assertEquals(CoverageRange.EXCELLENT, CoverageRange.valueOf(97.1));
assertNotNull(CoverageRange.fillColorOf(97.1));
assertNotNull(CoverageRange.EXCELLENT.getLineColor());
assertNotNull(CoverageRange.EXCELLENT.getFillHexString());
assertNotNull(CoverageRange.EXCELLENT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.EXCELLENT.getLineColor()));
assertTrue("Had " + 97.1 + " and floor " + CoverageRange.EXCELLENT.getFloor(), 97.1 < 0 || 97.1 >= CoverageRange.EXCELLENT.getFloor());
assertEquals(CoverageRange.PERFECT, CoverageRange.valueOf(100.0));
assertNotNull(CoverageRange.fillColorOf(100.0));
assertNotNull(CoverageRange.PERFECT.getLineColor());
assertNotNull(CoverageRange.PERFECT.getFillHexString());
assertNotNull(CoverageRange.PERFECT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.PERFECT.getLineColor()));
assertTrue("Had " + 100.0 + " and floor " + CoverageRange.PERFECT.getFloor(), 100.0 < 0 || 100.0 >= CoverageRange.PERFECT.getFloor());
assertEquals(CoverageRange.PERFECT, CoverageRange.valueOf(230.0));
assertNotNull(CoverageRange.fillColorOf(230.0));
assertNotNull(CoverageRange.PERFECT.getLineColor());
assertNotNull(CoverageRange.PERFECT.getFillHexString());
assertNotNull(CoverageRange.PERFECT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.PERFECT.getLineColor()));
assertTrue("Had " + 230.0 + " and floor " + CoverageRange.PERFECT.getFloor(), 230.0 < 0 || 230.0 >= CoverageRange.PERFECT.getFloor());
} | @Test
public void test() {
assertEquals(CoverageRange.ABYSSMAL, CoverageRange.valueOf(-20.0));
assertNotNull(CoverageRange.fillColorOf(-20.0));
assertNotNull(CoverageRange.ABYSSMAL.getLineColor());
assertNotNull(CoverageRange.ABYSSMAL.getFillHexString());
assertNotNull(CoverageRange.ABYSSMAL.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.ABYSSMAL.getLineColor()));
assertTrue("Had " + -20.0 + " and floor " + CoverageRange.ABYSSMAL.getFloor(), -20.0 < 0 || -20.0 >= CoverageRange.ABYSSMAL.getFloor());
assertEquals(CoverageRange.ABYSSMAL, CoverageRange.valueOf(0.0));
assertNotNull(CoverageRange.fillColorOf(0.0));
assertNotNull(CoverageRange.ABYSSMAL.getLineColor());
assertNotNull(CoverageRange.ABYSSMAL.getFillHexString());
assertNotNull(CoverageRange.ABYSSMAL.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.ABYSSMAL.getLineColor()));
assertTrue("Had " + 0.0 + " and floor " + CoverageRange.ABYSSMAL.getFloor(), 0.0 < 0 || 0.0 >= CoverageRange.ABYSSMAL.getFloor());
assertEquals(CoverageRange.ABYSSMAL, CoverageRange.valueOf(10.3));
assertNotNull(CoverageRange.fillColorOf(10.3));
assertNotNull(CoverageRange.ABYSSMAL.getLineColor());
assertNotNull(CoverageRange.ABYSSMAL.getFillHexString());
assertNotNull(CoverageRange.ABYSSMAL.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.ABYSSMAL.getLineColor()));
assertTrue("Had " + 10.3 + " and floor " + CoverageRange.ABYSSMAL.getFloor(), 10.3 < 0 || 10.3 >= CoverageRange.ABYSSMAL.getFloor());
assertEquals(CoverageRange.TRAGIC, CoverageRange.valueOf(25.0));
assertNotNull(CoverageRange.fillColorOf(25.0));
assertNotNull(CoverageRange.TRAGIC.getLineColor());
assertNotNull(CoverageRange.TRAGIC.getFillHexString());
assertNotNull(CoverageRange.TRAGIC.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.TRAGIC.getLineColor()));
assertTrue("Had " + 25.0 + " and floor " + CoverageRange.TRAGIC.getFloor(), 25.0 < 0 || 25.0 >= CoverageRange.TRAGIC.getFloor());
assertEquals(CoverageRange.TRAGIC, CoverageRange.valueOf(32.0));
assertNotNull(CoverageRange.fillColorOf(32.0));
assertNotNull(CoverageRange.TRAGIC.getLineColor());
assertNotNull(CoverageRange.TRAGIC.getFillHexString());
assertNotNull(CoverageRange.TRAGIC.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.TRAGIC.getLineColor()));
assertTrue("Had " + 32.0 + " and floor " + CoverageRange.TRAGIC.getFloor(), 32.0 < 0 || 32.0 >= CoverageRange.TRAGIC.getFloor());
assertEquals(CoverageRange.POOR, CoverageRange.valueOf(50.0));
assertNotNull(CoverageRange.fillColorOf(50.0));
assertNotNull(CoverageRange.POOR.getLineColor());
assertNotNull(CoverageRange.POOR.getFillHexString());
assertNotNull(CoverageRange.POOR.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.POOR.getLineColor()));
assertTrue("Had " + 50.0 + " and floor " + CoverageRange.POOR.getFloor(), 50.0 < 0 || 50.0 >= CoverageRange.POOR.getFloor());
assertEquals(CoverageRange.POOR, CoverageRange.valueOf(68.2));
assertNotNull(CoverageRange.fillColorOf(68.2));
assertNotNull(CoverageRange.POOR.getLineColor());
assertNotNull(CoverageRange.POOR.getFillHexString());
assertNotNull(CoverageRange.POOR.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.POOR.getLineColor()));
assertTrue("Had " + 68.2 + " and floor " + CoverageRange.POOR.getFloor(), 68.2 < 0 || 68.2 >= CoverageRange.POOR.getFloor());
assertEquals(CoverageRange.FAIR, CoverageRange.valueOf(75.0));
assertNotNull(CoverageRange.fillColorOf(75.0));
assertNotNull(CoverageRange.FAIR.getLineColor());
assertNotNull(CoverageRange.FAIR.getFillHexString());
assertNotNull(CoverageRange.FAIR.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.FAIR.getLineColor()));
assertTrue("Had " + 75.0 + " and floor " + CoverageRange.FAIR.getFloor(), 75.0 < 0 || 75.0 >= CoverageRange.FAIR.getFloor());
assertEquals(CoverageRange.FAIR, CoverageRange.valueOf(83.0));
assertNotNull(CoverageRange.fillColorOf(83.0));
assertNotNull(CoverageRange.FAIR.getLineColor());
assertNotNull(CoverageRange.FAIR.getFillHexString());
assertNotNull(CoverageRange.FAIR.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.FAIR.getLineColor()));
assertTrue("Had " + 83.0 + " and floor " + CoverageRange.FAIR.getFloor(), 83.0 < 0 || 83.0 >= CoverageRange.FAIR.getFloor());
assertEquals(CoverageRange.SUFFICIENT, CoverageRange.valueOf(85.0));
assertNotNull(CoverageRange.fillColorOf(85.0));
assertNotNull(CoverageRange.SUFFICIENT.getLineColor());
assertNotNull(CoverageRange.SUFFICIENT.getFillHexString());
assertNotNull(CoverageRange.SUFFICIENT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.SUFFICIENT.getLineColor()));
assertTrue("Had " + 85.0 + " and floor " + CoverageRange.SUFFICIENT.getFloor(), 85.0 < 0 || 85.0 >= CoverageRange.SUFFICIENT.getFloor());
assertEquals(CoverageRange.SUFFICIENT, CoverageRange.valueOf(91.0));
assertNotNull(CoverageRange.fillColorOf(91.0));
assertNotNull(CoverageRange.SUFFICIENT.getLineColor());
assertNotNull(CoverageRange.SUFFICIENT.getFillHexString());
assertNotNull(CoverageRange.SUFFICIENT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.SUFFICIENT.getLineColor()));
assertTrue("Had " + 91.0 + " and floor " + CoverageRange.SUFFICIENT.getFloor(), 91.0 < 0 || 91.0 >= CoverageRange.SUFFICIENT.getFloor());
assertEquals(CoverageRange.GOOD, CoverageRange.valueOf(92.0));
assertNotNull(CoverageRange.fillColorOf(92.0));
assertNotNull(CoverageRange.GOOD.getLineColor());
assertNotNull(CoverageRange.GOOD.getFillHexString());
assertNotNull(CoverageRange.GOOD.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.GOOD.getLineColor()));
assertTrue("Had " + 92.0 + " and floor " + CoverageRange.GOOD.getFloor(), 92.0 < 0 || 92.0 >= CoverageRange.GOOD.getFloor());
assertEquals(CoverageRange.GOOD, CoverageRange.valueOf(96.999));
assertNotNull(CoverageRange.fillColorOf(96.999));
assertNotNull(CoverageRange.GOOD.getLineColor());
assertNotNull(CoverageRange.GOOD.getFillHexString());
assertNotNull(CoverageRange.GOOD.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.GOOD.getLineColor()));
assertTrue("Had " + 96.999 + " and floor " + CoverageRange.GOOD.getFloor(), 96.999 < 0 || 96.999 >= CoverageRange.GOOD.getFloor());
assertEquals(CoverageRange.EXCELLENT, CoverageRange.valueOf(97.0));
assertNotNull(CoverageRange.fillColorOf(97.0));
assertNotNull(CoverageRange.EXCELLENT.getLineColor());
assertNotNull(CoverageRange.EXCELLENT.getFillHexString());
assertNotNull(CoverageRange.EXCELLENT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.EXCELLENT.getLineColor()));
assertTrue("Had " + 97.0 + " and floor " + CoverageRange.EXCELLENT.getFloor(), 97.0 < 0 || 97.0 >= CoverageRange.EXCELLENT.getFloor());
assertEquals(CoverageRange.EXCELLENT, CoverageRange.valueOf(97.1));
assertNotNull(CoverageRange.fillColorOf(97.1));
assertNotNull(CoverageRange.EXCELLENT.getLineColor());
assertNotNull(CoverageRange.EXCELLENT.getFillHexString());
assertNotNull(CoverageRange.EXCELLENT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.EXCELLENT.getLineColor()));
assertTrue("Had " + 97.1 + " and floor " + CoverageRange.EXCELLENT.getFloor(), 97.1 < 0 || 97.1 >= CoverageRange.EXCELLENT.getFloor());
assertEquals(CoverageRange.PERFECT, CoverageRange.valueOf(100.0));
assertNotNull(CoverageRange.fillColorOf(100.0));
assertNotNull(CoverageRange.PERFECT.getLineColor());
assertNotNull(CoverageRange.PERFECT.getFillHexString());
assertNotNull(CoverageRange.PERFECT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.PERFECT.getLineColor()));
assertTrue("Had " + 100.0 + " and floor " + CoverageRange.PERFECT.getFloor(), 100.0 < 0 || 100.0 >= CoverageRange.PERFECT.getFloor());
<DeepExtract>
assertEquals(CoverageRange.PERFECT, CoverageRange.valueOf(230.0));
assertNotNull(CoverageRange.fillColorOf(230.0));
assertNotNull(CoverageRange.PERFECT.getLineColor());
assertNotNull(CoverageRange.PERFECT.getFillHexString());
assertNotNull(CoverageRange.PERFECT.getLineHexString());
assertNotNull(CoverageRange.colorAsHexString(CoverageRange.PERFECT.getLineColor()));
assertTrue("Had " + 230.0 + " and floor " + CoverageRange.PERFECT.getFloor(), 230.0 < 0 || 230.0 >= CoverageRange.PERFECT.getFloor());
</DeepExtract>
} | jacoco-plugin | positive | 504 |
public static int[] shorten(final int[] list) {
final boolean[] output = new boolean[list.length - 1];
System.arraycopy(list, 0, output, 0, list.length - 1);
return output;
} | public static int[] shorten(final int[] list) {
<DeepExtract>
final boolean[] output = new boolean[list.length - 1];
System.arraycopy(list, 0, output, 0, list.length - 1);
return output;
</DeepExtract>
} | rainbow | positive | 505 |
@Override
public void handleEvent(Event event) {
TableColumn[] columns = viewer.getTable().getColumns();
int[] newWidths = new int[columns.length - 1];
int i = 0;
boolean first = true;
for (TableColumn col : columns) {
if (first) {
first = false;
continue;
}
newWidths[i++] = col.getWidth();
}
columnConfig.update(columnConfig.getFields(), newWidths);
} | @Override
public void handleEvent(Event event) {
<DeepExtract>
TableColumn[] columns = viewer.getTable().getColumns();
int[] newWidths = new int[columns.length - 1];
int i = 0;
boolean first = true;
for (TableColumn col : columns) {
if (first) {
first = false;
continue;
}
newWidths[i++] = col.getWidth();
}
columnConfig.update(columnConfig.getFields(), newWidths);
</DeepExtract>
} | logsaw-app | positive | 506 |
private void performRefreshComplete() {
mStatus = PTR_STATUS_COMPLETE;
if (mScrollChecker.mIsRunning && isAutoRefresh()) {
if (DEBUG) {
PtrCLog.d(LOG_TAG, "performRefreshComplete do nothing, scrolling: %s, auto refresh: %s", mScrollChecker.mIsRunning, mFlag);
}
return;
}
if (mPtrIndicator.hasLeftStartPosition() && !false && mRefreshCompleteHook != null) {
if (DEBUG) {
PtrCLog.d(LOG_TAG, "notifyUIRefreshComplete mRefreshCompleteHook run.");
}
mRefreshCompleteHook.takeOver();
return;
}
if (mPtrUIHandlerHolder.hasHandler()) {
if (DEBUG) {
PtrCLog.i(LOG_TAG, "PtrUIHandler: onUIRefreshComplete");
}
mPtrUIHandlerHolder.onUIRefreshComplete(this);
}
mPtrIndicator.onUIRefreshComplete();
tryScrollBackToTopAfterComplete();
tryToNotifyReset();
} | private void performRefreshComplete() {
mStatus = PTR_STATUS_COMPLETE;
if (mScrollChecker.mIsRunning && isAutoRefresh()) {
if (DEBUG) {
PtrCLog.d(LOG_TAG, "performRefreshComplete do nothing, scrolling: %s, auto refresh: %s", mScrollChecker.mIsRunning, mFlag);
}
return;
}
<DeepExtract>
if (mPtrIndicator.hasLeftStartPosition() && !false && mRefreshCompleteHook != null) {
if (DEBUG) {
PtrCLog.d(LOG_TAG, "notifyUIRefreshComplete mRefreshCompleteHook run.");
}
mRefreshCompleteHook.takeOver();
return;
}
if (mPtrUIHandlerHolder.hasHandler()) {
if (DEBUG) {
PtrCLog.i(LOG_TAG, "PtrUIHandler: onUIRefreshComplete");
}
mPtrUIHandlerHolder.onUIRefreshComplete(this);
}
mPtrIndicator.onUIRefreshComplete();
tryScrollBackToTopAfterComplete();
tryToNotifyReset();
</DeepExtract>
} | Android-rxjava-retrofit-okhttp-app | positive | 507 |
@EventHandler()
public void onDeath(PlayerDeathEvent event) {
Player p = event.getEntity();
if (NPCChecker.isNPC(p))
return;
event.getDrops().removeIf(item -> {
if (item == null)
return true;
if (item.hasItemMeta()) {
return UTEi18n.cache("item.locked").equalsIgnoreCase(item.getItemMeta().getDisplayName());
}
return false;
});
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null)
return;
if (EditAction.SET == null)
EditAction.SET = EditAction.INCREMENT;
if (event.getEntity() == null)
return;
if (CheckType.TEMPERATURE == null)
return;
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null) {
Logging.getLogger().log(Level.SEVERE, "Failed found player data for " + event.getEntity().getName() + ", " + "{class=" + event.getEntity().getClass() + ", uuid=" + event.getEntity().getUniqueId() + "}", new Throwable("Trace Stack Dump"));
return;
}
String mark;
if (getDefault(ip, CheckType.TEMPERATURE, p) > 0)
mark = "↑";
else if (getDefault(ip, CheckType.TEMPERATURE, p) < 0)
mark = "↓";
else
mark = " ";
switch(CheckType.TEMPERATURE) {
case TEMPERATURE:
EditAction.SET.update(() -> ip.temperature, v -> ip.temperature = v, getDefault(ip, CheckType.TEMPERATURE, p));
HudProvider.temperature.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.temperature.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.temperature <= 10)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-cool"), "");
if (ip.temperature >= 60)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-hot"), "");
if (ip.temperature < -5)
ip.temperature = -5;
if (ip.temperature > 75)
ip.temperature = 75;
break;
case HUMIDITY:
EditAction.SET.update(() -> ip.humidity, v -> ip.humidity = v, getDefault(ip, CheckType.TEMPERATURE, p));
HudProvider.humidity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.humidity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.humidity < 0)
ip.humidity = 0;
if (ip.humidity > 100)
ip.humidity = 100;
break;
case SANITY:
EditAction.SET.update(() -> ip.sanity, v -> ip.sanity = v, getDefault(ip, CheckType.TEMPERATURE, p));
HudProvider.sanity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.sanity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.sanity < 0)
ip.sanity = 0;
if (ip.sanity > ip.roleStats.sanMax)
ip.sanity = ip.roleStats.sanMax;
break;
case TIREDNESS:
EditAction.SET.update(() -> ip.tiredness, v -> ip.tiredness = v, getDefault(ip, CheckType.TEMPERATURE, p));
HudProvider.tiredness.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.tiredness.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.tiredness < 0)
ip.tiredness = 0;
if (ip.tiredness > 100)
ip.tiredness = 100;
break;
case DAMAGELEVEL:
EditAction.SET.update(() -> ip.roleStats.damageLevel, v -> ip.roleStats.damageLevel = v, getDefault(ip, CheckType.TEMPERATURE, p));
break;
case HEALTHMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.healthMax, v -> ip.roleStats.healthMax = v, (int) getDefault(ip, CheckType.TEMPERATURE, p));
break;
case LEVEL:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.level, v -> ip.roleStats.level = v, (int) getDefault(ip, CheckType.TEMPERATURE, p));
break;
case SANMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.sanMax, v -> ip.roleStats.sanMax = v, (int) getDefault(ip, CheckType.TEMPERATURE, p));
break;
}
if (EditAction.SET == null)
EditAction.SET = EditAction.INCREMENT;
if (event.getEntity() == null)
return;
if (CheckType.HUMIDITY == null)
return;
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null) {
Logging.getLogger().log(Level.SEVERE, "Failed found player data for " + event.getEntity().getName() + ", " + "{class=" + event.getEntity().getClass() + ", uuid=" + event.getEntity().getUniqueId() + "}", new Throwable("Trace Stack Dump"));
return;
}
String mark;
if (getDefault(ip, CheckType.HUMIDITY, p) > 0)
mark = "↑";
else if (getDefault(ip, CheckType.HUMIDITY, p) < 0)
mark = "↓";
else
mark = " ";
switch(CheckType.HUMIDITY) {
case TEMPERATURE:
EditAction.SET.update(() -> ip.temperature, v -> ip.temperature = v, getDefault(ip, CheckType.HUMIDITY, p));
HudProvider.temperature.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.temperature.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.temperature <= 10)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-cool"), "");
if (ip.temperature >= 60)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-hot"), "");
if (ip.temperature < -5)
ip.temperature = -5;
if (ip.temperature > 75)
ip.temperature = 75;
break;
case HUMIDITY:
EditAction.SET.update(() -> ip.humidity, v -> ip.humidity = v, getDefault(ip, CheckType.HUMIDITY, p));
HudProvider.humidity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.humidity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.humidity < 0)
ip.humidity = 0;
if (ip.humidity > 100)
ip.humidity = 100;
break;
case SANITY:
EditAction.SET.update(() -> ip.sanity, v -> ip.sanity = v, getDefault(ip, CheckType.HUMIDITY, p));
HudProvider.sanity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.sanity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.sanity < 0)
ip.sanity = 0;
if (ip.sanity > ip.roleStats.sanMax)
ip.sanity = ip.roleStats.sanMax;
break;
case TIREDNESS:
EditAction.SET.update(() -> ip.tiredness, v -> ip.tiredness = v, getDefault(ip, CheckType.HUMIDITY, p));
HudProvider.tiredness.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.tiredness.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.tiredness < 0)
ip.tiredness = 0;
if (ip.tiredness > 100)
ip.tiredness = 100;
break;
case DAMAGELEVEL:
EditAction.SET.update(() -> ip.roleStats.damageLevel, v -> ip.roleStats.damageLevel = v, getDefault(ip, CheckType.HUMIDITY, p));
break;
case HEALTHMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.healthMax, v -> ip.roleStats.healthMax = v, (int) getDefault(ip, CheckType.HUMIDITY, p));
break;
case LEVEL:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.level, v -> ip.roleStats.level = v, (int) getDefault(ip, CheckType.HUMIDITY, p));
break;
case SANMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.sanMax, v -> ip.roleStats.sanMax = v, (int) getDefault(ip, CheckType.HUMIDITY, p));
break;
}
if (EditAction.SET == null)
EditAction.SET = EditAction.INCREMENT;
if (event.getEntity() == null)
return;
if (CheckType.SANITY == null)
return;
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null) {
Logging.getLogger().log(Level.SEVERE, "Failed found player data for " + event.getEntity().getName() + ", " + "{class=" + event.getEntity().getClass() + ", uuid=" + event.getEntity().getUniqueId() + "}", new Throwable("Trace Stack Dump"));
return;
}
String mark;
if (getDefault(ip, CheckType.SANITY, p) > 0)
mark = "↑";
else if (getDefault(ip, CheckType.SANITY, p) < 0)
mark = "↓";
else
mark = " ";
switch(CheckType.SANITY) {
case TEMPERATURE:
EditAction.SET.update(() -> ip.temperature, v -> ip.temperature = v, getDefault(ip, CheckType.SANITY, p));
HudProvider.temperature.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.temperature.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.temperature <= 10)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-cool"), "");
if (ip.temperature >= 60)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-hot"), "");
if (ip.temperature < -5)
ip.temperature = -5;
if (ip.temperature > 75)
ip.temperature = 75;
break;
case HUMIDITY:
EditAction.SET.update(() -> ip.humidity, v -> ip.humidity = v, getDefault(ip, CheckType.SANITY, p));
HudProvider.humidity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.humidity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.humidity < 0)
ip.humidity = 0;
if (ip.humidity > 100)
ip.humidity = 100;
break;
case SANITY:
EditAction.SET.update(() -> ip.sanity, v -> ip.sanity = v, getDefault(ip, CheckType.SANITY, p));
HudProvider.sanity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.sanity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.sanity < 0)
ip.sanity = 0;
if (ip.sanity > ip.roleStats.sanMax)
ip.sanity = ip.roleStats.sanMax;
break;
case TIREDNESS:
EditAction.SET.update(() -> ip.tiredness, v -> ip.tiredness = v, getDefault(ip, CheckType.SANITY, p));
HudProvider.tiredness.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.tiredness.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.tiredness < 0)
ip.tiredness = 0;
if (ip.tiredness > 100)
ip.tiredness = 100;
break;
case DAMAGELEVEL:
EditAction.SET.update(() -> ip.roleStats.damageLevel, v -> ip.roleStats.damageLevel = v, getDefault(ip, CheckType.SANITY, p));
break;
case HEALTHMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.healthMax, v -> ip.roleStats.healthMax = v, (int) getDefault(ip, CheckType.SANITY, p));
break;
case LEVEL:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.level, v -> ip.roleStats.level = v, (int) getDefault(ip, CheckType.SANITY, p));
break;
case SANMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.sanMax, v -> ip.roleStats.sanMax = v, (int) getDefault(ip, CheckType.SANITY, p));
break;
}
if (EditAction.SET == null)
EditAction.SET = EditAction.INCREMENT;
if (event.getEntity() == null)
return;
if (CheckType.TIREDNESS == null)
return;
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null) {
Logging.getLogger().log(Level.SEVERE, "Failed found player data for " + event.getEntity().getName() + ", " + "{class=" + event.getEntity().getClass() + ", uuid=" + event.getEntity().getUniqueId() + "}", new Throwable("Trace Stack Dump"));
return;
}
String mark;
if (getDefault(ip, CheckType.TIREDNESS, p) > 0)
mark = "↑";
else if (getDefault(ip, CheckType.TIREDNESS, p) < 0)
mark = "↓";
else
mark = " ";
switch(CheckType.TIREDNESS) {
case TEMPERATURE:
EditAction.SET.update(() -> ip.temperature, v -> ip.temperature = v, getDefault(ip, CheckType.TIREDNESS, p));
HudProvider.temperature.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.temperature.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.temperature <= 10)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-cool"), "");
if (ip.temperature >= 60)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-hot"), "");
if (ip.temperature < -5)
ip.temperature = -5;
if (ip.temperature > 75)
ip.temperature = 75;
break;
case HUMIDITY:
EditAction.SET.update(() -> ip.humidity, v -> ip.humidity = v, getDefault(ip, CheckType.TIREDNESS, p));
HudProvider.humidity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.humidity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.humidity < 0)
ip.humidity = 0;
if (ip.humidity > 100)
ip.humidity = 100;
break;
case SANITY:
EditAction.SET.update(() -> ip.sanity, v -> ip.sanity = v, getDefault(ip, CheckType.TIREDNESS, p));
HudProvider.sanity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.sanity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.sanity < 0)
ip.sanity = 0;
if (ip.sanity > ip.roleStats.sanMax)
ip.sanity = ip.roleStats.sanMax;
break;
case TIREDNESS:
EditAction.SET.update(() -> ip.tiredness, v -> ip.tiredness = v, getDefault(ip, CheckType.TIREDNESS, p));
HudProvider.tiredness.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.tiredness.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.tiredness < 0)
ip.tiredness = 0;
if (ip.tiredness > 100)
ip.tiredness = 100;
break;
case DAMAGELEVEL:
EditAction.SET.update(() -> ip.roleStats.damageLevel, v -> ip.roleStats.damageLevel = v, getDefault(ip, CheckType.TIREDNESS, p));
break;
case HEALTHMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.healthMax, v -> ip.roleStats.healthMax = v, (int) getDefault(ip, CheckType.TIREDNESS, p));
break;
case LEVEL:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.level, v -> ip.roleStats.level = v, (int) getDefault(ip, CheckType.TIREDNESS, p));
break;
case SANMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.sanMax, v -> ip.roleStats.sanMax = v, (int) getDefault(ip, CheckType.TIREDNESS, p));
break;
}
if (RolesSettings.resetRoleOnPlayerDeath) {
changeRole(event.getEntity(), Roles.DEFAULT);
playerChangedRole.remove(event.getEntity().getUniqueId());
}
Logging.getLogger().log(Level.FINER, "Saving save for " + event.getEntity());
Map<String, Object> data = new HashMap<>();
IPlayer player = players.get(event.getEntity().getUniqueId());
data.put("humidity", player.humidity);
data.put("temperature", player.temperature);
data.put("sanity", player.sanity);
data.put("tiredness", player.tiredness);
data.put("role", player.role.toString());
data.put("level", player.roleStats.level);
data.put("sanMax", player.roleStats.sanMax);
data.put("healthMax", player.roleStats.healthMax);
data.put("damageLevel", player.roleStats.damageLevel);
data.put("unlockedRecipes", player.unlockedRecipes);
try {
PlayerDataLoaderImpl.loader.save(playerdata, event.getEntity(), data);
} catch (IOException e) {
Logging.getLogger().log(Level.WARNING, "Failed save data for " + event.getEntity(), e);
}
} | @EventHandler()
public void onDeath(PlayerDeathEvent event) {
Player p = event.getEntity();
if (NPCChecker.isNPC(p))
return;
event.getDrops().removeIf(item -> {
if (item == null)
return true;
if (item.hasItemMeta()) {
return UTEi18n.cache("item.locked").equalsIgnoreCase(item.getItemMeta().getDisplayName());
}
return false;
});
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null)
return;
if (EditAction.SET == null)
EditAction.SET = EditAction.INCREMENT;
if (event.getEntity() == null)
return;
if (CheckType.TEMPERATURE == null)
return;
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null) {
Logging.getLogger().log(Level.SEVERE, "Failed found player data for " + event.getEntity().getName() + ", " + "{class=" + event.getEntity().getClass() + ", uuid=" + event.getEntity().getUniqueId() + "}", new Throwable("Trace Stack Dump"));
return;
}
String mark;
if (getDefault(ip, CheckType.TEMPERATURE, p) > 0)
mark = "↑";
else if (getDefault(ip, CheckType.TEMPERATURE, p) < 0)
mark = "↓";
else
mark = " ";
switch(CheckType.TEMPERATURE) {
case TEMPERATURE:
EditAction.SET.update(() -> ip.temperature, v -> ip.temperature = v, getDefault(ip, CheckType.TEMPERATURE, p));
HudProvider.temperature.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.temperature.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.temperature <= 10)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-cool"), "");
if (ip.temperature >= 60)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-hot"), "");
if (ip.temperature < -5)
ip.temperature = -5;
if (ip.temperature > 75)
ip.temperature = 75;
break;
case HUMIDITY:
EditAction.SET.update(() -> ip.humidity, v -> ip.humidity = v, getDefault(ip, CheckType.TEMPERATURE, p));
HudProvider.humidity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.humidity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.humidity < 0)
ip.humidity = 0;
if (ip.humidity > 100)
ip.humidity = 100;
break;
case SANITY:
EditAction.SET.update(() -> ip.sanity, v -> ip.sanity = v, getDefault(ip, CheckType.TEMPERATURE, p));
HudProvider.sanity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.sanity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.sanity < 0)
ip.sanity = 0;
if (ip.sanity > ip.roleStats.sanMax)
ip.sanity = ip.roleStats.sanMax;
break;
case TIREDNESS:
EditAction.SET.update(() -> ip.tiredness, v -> ip.tiredness = v, getDefault(ip, CheckType.TEMPERATURE, p));
HudProvider.tiredness.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.tiredness.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.tiredness < 0)
ip.tiredness = 0;
if (ip.tiredness > 100)
ip.tiredness = 100;
break;
case DAMAGELEVEL:
EditAction.SET.update(() -> ip.roleStats.damageLevel, v -> ip.roleStats.damageLevel = v, getDefault(ip, CheckType.TEMPERATURE, p));
break;
case HEALTHMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.healthMax, v -> ip.roleStats.healthMax = v, (int) getDefault(ip, CheckType.TEMPERATURE, p));
break;
case LEVEL:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.level, v -> ip.roleStats.level = v, (int) getDefault(ip, CheckType.TEMPERATURE, p));
break;
case SANMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.sanMax, v -> ip.roleStats.sanMax = v, (int) getDefault(ip, CheckType.TEMPERATURE, p));
break;
}
if (EditAction.SET == null)
EditAction.SET = EditAction.INCREMENT;
if (event.getEntity() == null)
return;
if (CheckType.HUMIDITY == null)
return;
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null) {
Logging.getLogger().log(Level.SEVERE, "Failed found player data for " + event.getEntity().getName() + ", " + "{class=" + event.getEntity().getClass() + ", uuid=" + event.getEntity().getUniqueId() + "}", new Throwable("Trace Stack Dump"));
return;
}
String mark;
if (getDefault(ip, CheckType.HUMIDITY, p) > 0)
mark = "↑";
else if (getDefault(ip, CheckType.HUMIDITY, p) < 0)
mark = "↓";
else
mark = " ";
switch(CheckType.HUMIDITY) {
case TEMPERATURE:
EditAction.SET.update(() -> ip.temperature, v -> ip.temperature = v, getDefault(ip, CheckType.HUMIDITY, p));
HudProvider.temperature.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.temperature.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.temperature <= 10)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-cool"), "");
if (ip.temperature >= 60)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-hot"), "");
if (ip.temperature < -5)
ip.temperature = -5;
if (ip.temperature > 75)
ip.temperature = 75;
break;
case HUMIDITY:
EditAction.SET.update(() -> ip.humidity, v -> ip.humidity = v, getDefault(ip, CheckType.HUMIDITY, p));
HudProvider.humidity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.humidity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.humidity < 0)
ip.humidity = 0;
if (ip.humidity > 100)
ip.humidity = 100;
break;
case SANITY:
EditAction.SET.update(() -> ip.sanity, v -> ip.sanity = v, getDefault(ip, CheckType.HUMIDITY, p));
HudProvider.sanity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.sanity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.sanity < 0)
ip.sanity = 0;
if (ip.sanity > ip.roleStats.sanMax)
ip.sanity = ip.roleStats.sanMax;
break;
case TIREDNESS:
EditAction.SET.update(() -> ip.tiredness, v -> ip.tiredness = v, getDefault(ip, CheckType.HUMIDITY, p));
HudProvider.tiredness.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.tiredness.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.tiredness < 0)
ip.tiredness = 0;
if (ip.tiredness > 100)
ip.tiredness = 100;
break;
case DAMAGELEVEL:
EditAction.SET.update(() -> ip.roleStats.damageLevel, v -> ip.roleStats.damageLevel = v, getDefault(ip, CheckType.HUMIDITY, p));
break;
case HEALTHMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.healthMax, v -> ip.roleStats.healthMax = v, (int) getDefault(ip, CheckType.HUMIDITY, p));
break;
case LEVEL:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.level, v -> ip.roleStats.level = v, (int) getDefault(ip, CheckType.HUMIDITY, p));
break;
case SANMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.sanMax, v -> ip.roleStats.sanMax = v, (int) getDefault(ip, CheckType.HUMIDITY, p));
break;
}
if (EditAction.SET == null)
EditAction.SET = EditAction.INCREMENT;
if (event.getEntity() == null)
return;
if (CheckType.SANITY == null)
return;
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null) {
Logging.getLogger().log(Level.SEVERE, "Failed found player data for " + event.getEntity().getName() + ", " + "{class=" + event.getEntity().getClass() + ", uuid=" + event.getEntity().getUniqueId() + "}", new Throwable("Trace Stack Dump"));
return;
}
String mark;
if (getDefault(ip, CheckType.SANITY, p) > 0)
mark = "↑";
else if (getDefault(ip, CheckType.SANITY, p) < 0)
mark = "↓";
else
mark = " ";
switch(CheckType.SANITY) {
case TEMPERATURE:
EditAction.SET.update(() -> ip.temperature, v -> ip.temperature = v, getDefault(ip, CheckType.SANITY, p));
HudProvider.temperature.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.temperature.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.temperature <= 10)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-cool"), "");
if (ip.temperature >= 60)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-hot"), "");
if (ip.temperature < -5)
ip.temperature = -5;
if (ip.temperature > 75)
ip.temperature = 75;
break;
case HUMIDITY:
EditAction.SET.update(() -> ip.humidity, v -> ip.humidity = v, getDefault(ip, CheckType.SANITY, p));
HudProvider.humidity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.humidity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.humidity < 0)
ip.humidity = 0;
if (ip.humidity > 100)
ip.humidity = 100;
break;
case SANITY:
EditAction.SET.update(() -> ip.sanity, v -> ip.sanity = v, getDefault(ip, CheckType.SANITY, p));
HudProvider.sanity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.sanity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.sanity < 0)
ip.sanity = 0;
if (ip.sanity > ip.roleStats.sanMax)
ip.sanity = ip.roleStats.sanMax;
break;
case TIREDNESS:
EditAction.SET.update(() -> ip.tiredness, v -> ip.tiredness = v, getDefault(ip, CheckType.SANITY, p));
HudProvider.tiredness.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.tiredness.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.tiredness < 0)
ip.tiredness = 0;
if (ip.tiredness > 100)
ip.tiredness = 100;
break;
case DAMAGELEVEL:
EditAction.SET.update(() -> ip.roleStats.damageLevel, v -> ip.roleStats.damageLevel = v, getDefault(ip, CheckType.SANITY, p));
break;
case HEALTHMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.healthMax, v -> ip.roleStats.healthMax = v, (int) getDefault(ip, CheckType.SANITY, p));
break;
case LEVEL:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.level, v -> ip.roleStats.level = v, (int) getDefault(ip, CheckType.SANITY, p));
break;
case SANMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.sanMax, v -> ip.roleStats.sanMax = v, (int) getDefault(ip, CheckType.SANITY, p));
break;
}
if (EditAction.SET == null)
EditAction.SET = EditAction.INCREMENT;
if (event.getEntity() == null)
return;
if (CheckType.TIREDNESS == null)
return;
IPlayer ip = players.get(event.getEntity().getUniqueId());
if (ip == null) {
Logging.getLogger().log(Level.SEVERE, "Failed found player data for " + event.getEntity().getName() + ", " + "{class=" + event.getEntity().getClass() + ", uuid=" + event.getEntity().getUniqueId() + "}", new Throwable("Trace Stack Dump"));
return;
}
String mark;
if (getDefault(ip, CheckType.TIREDNESS, p) > 0)
mark = "↑";
else if (getDefault(ip, CheckType.TIREDNESS, p) < 0)
mark = "↓";
else
mark = " ";
switch(CheckType.TIREDNESS) {
case TEMPERATURE:
EditAction.SET.update(() -> ip.temperature, v -> ip.temperature = v, getDefault(ip, CheckType.TIREDNESS, p));
HudProvider.temperature.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.temperature.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.temperature <= 10)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-cool"), "");
if (ip.temperature >= 60)
event.getEntity().sendTitle(UTEi18n.cache("mechanism.temperature.to-hot"), "");
if (ip.temperature < -5)
ip.temperature = -5;
if (ip.temperature > 75)
ip.temperature = 75;
break;
case HUMIDITY:
EditAction.SET.update(() -> ip.humidity, v -> ip.humidity = v, getDefault(ip, CheckType.TIREDNESS, p));
HudProvider.humidity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.humidity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.humidity < 0)
ip.humidity = 0;
if (ip.humidity > 100)
ip.humidity = 100;
break;
case SANITY:
EditAction.SET.update(() -> ip.sanity, v -> ip.sanity = v, getDefault(ip, CheckType.TIREDNESS, p));
HudProvider.sanity.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.sanity.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.sanity < 0)
ip.sanity = 0;
if (ip.sanity > ip.roleStats.sanMax)
ip.sanity = ip.roleStats.sanMax;
break;
case TIREDNESS:
EditAction.SET.update(() -> ip.tiredness, v -> ip.tiredness = v, getDefault(ip, CheckType.TIREDNESS, p));
HudProvider.tiredness.put(event.getEntity().getUniqueId(), mark);
new BukkitRunnable() {
@Override
public void run() {
HudProvider.tiredness.computeIfPresent(event.getEntity().getUniqueId(), buildMarkFunc(mark));
}
}.runTaskLater(plugin, 40L);
if (ip.tiredness < 0)
ip.tiredness = 0;
if (ip.tiredness > 100)
ip.tiredness = 100;
break;
case DAMAGELEVEL:
EditAction.SET.update(() -> ip.roleStats.damageLevel, v -> ip.roleStats.damageLevel = v, getDefault(ip, CheckType.TIREDNESS, p));
break;
case HEALTHMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.healthMax, v -> ip.roleStats.healthMax = v, (int) getDefault(ip, CheckType.TIREDNESS, p));
break;
case LEVEL:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.level, v -> ip.roleStats.level = v, (int) getDefault(ip, CheckType.TIREDNESS, p));
break;
case SANMAX:
EditAction.SET.update((IntSupplier) () -> ip.roleStats.sanMax, v -> ip.roleStats.sanMax = v, (int) getDefault(ip, CheckType.TIREDNESS, p));
break;
}
if (RolesSettings.resetRoleOnPlayerDeath) {
changeRole(event.getEntity(), Roles.DEFAULT);
playerChangedRole.remove(event.getEntity().getUniqueId());
}
<DeepExtract>
Logging.getLogger().log(Level.FINER, "Saving save for " + event.getEntity());
Map<String, Object> data = new HashMap<>();
IPlayer player = players.get(event.getEntity().getUniqueId());
data.put("humidity", player.humidity);
data.put("temperature", player.temperature);
data.put("sanity", player.sanity);
data.put("tiredness", player.tiredness);
data.put("role", player.role.toString());
data.put("level", player.roleStats.level);
data.put("sanMax", player.roleStats.sanMax);
data.put("healthMax", player.roleStats.healthMax);
data.put("damageLevel", player.roleStats.damageLevel);
data.put("unlockedRecipes", player.unlockedRecipes);
try {
PlayerDataLoaderImpl.loader.save(playerdata, event.getEntity(), data);
} catch (IOException e) {
Logging.getLogger().log(Level.WARNING, "Failed save data for " + event.getEntity(), e);
}
</DeepExtract>
} | UntilTheEnd | positive | 508 |
@Override
public void onClickYes() {
button.setText("登录");
button.setEnabled(true);
etAccount.setEnabled(true);
etPwd.setEnabled(true);
etPwd2.setEnabled(true);
progressBar.setVisibility(View.GONE);
} | @Override
public void onClickYes() {
<DeepExtract>
button.setText("登录");
button.setEnabled(true);
etAccount.setEnabled(true);
etPwd.setEnabled(true);
etPwd2.setEnabled(true);
progressBar.setVisibility(View.GONE);
</DeepExtract>
} | GuetClassTable | positive | 509 |
public String getFormatTotalSize() {
String displaySize;
if (totalSize.divide(ONE_EB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_EB_BI)) + " EB";
} else if (totalSize.divide(ONE_PB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_PB_BI)) + " PB";
} else if (totalSize.divide(ONE_TB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_TB_BI)) + " TB";
} else if (totalSize.divide(ONE_GB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_GB_BI)) + " GB";
} else if (totalSize.divide(ONE_MB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_MB_BI)) + " MB";
} else if (totalSize.divide(ONE_KB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_KB_BI)) + " KB";
} else {
displaySize = String.valueOf(totalSize) + " bytes";
}
return displaySize;
} | public String getFormatTotalSize() {
<DeepExtract>
String displaySize;
if (totalSize.divide(ONE_EB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_EB_BI)) + " EB";
} else if (totalSize.divide(ONE_PB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_PB_BI)) + " PB";
} else if (totalSize.divide(ONE_TB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_TB_BI)) + " TB";
} else if (totalSize.divide(ONE_GB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_GB_BI)) + " GB";
} else if (totalSize.divide(ONE_MB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_MB_BI)) + " MB";
} else if (totalSize.divide(ONE_KB_BI).compareTo(BigInteger.ZERO) > 0) {
displaySize = String.valueOf(totalSize.divide(ONE_KB_BI)) + " KB";
} else {
displaySize = String.valueOf(totalSize) + " bytes";
}
return displaySize;
</DeepExtract>
} | XinFrameworkLib | positive | 510 |
@Nullable
private JsonPointer getMatchingPointer(final JsonRef ref) {
if (otherRefs.containsKey(ref))
return otherRefs.get(ref);
if (!ref.isLegal())
return null;
final JsonPointer refPtr = ref.getPointer();
for (final Map.Entry<JsonRef, JsonPointer> entry : absRefs.entrySet()) if (entry.getKey().contains(ref))
return entry.getValue().append(refPtr);
return key.getLoadingRef().contains(ref) ? refPtr : null;
} | @Nullable
private JsonPointer getMatchingPointer(final JsonRef ref) {
if (otherRefs.containsKey(ref))
return otherRefs.get(ref);
if (!ref.isLegal())
return null;
<DeepExtract>
final JsonPointer refPtr = ref.getPointer();
for (final Map.Entry<JsonRef, JsonPointer> entry : absRefs.entrySet()) if (entry.getKey().contains(ref))
return entry.getValue().append(refPtr);
return key.getLoadingRef().contains(ref) ? refPtr : null;
</DeepExtract>
} | json-schema-core | positive | 511 |
public MSSRegistrationReq createRegistrationReq(final String apTransId) {
MSSRegistrationReq req = mssObjFactory.createMSSRegistrationReq();
if (req == null)
throw new IllegalArgumentException("Invalid request (null)");
req.setMajorVersion(Long.valueOf(1));
req.setMinorVersion(Long.valueOf(1));
if (apTransId != null) {
final MessageAbstractType.APInfo aiObject = mssObjFactory.createMessageAbstractTypeAPInfo();
aiObject.setAPID(this.apId);
aiObject.setAPPWD(this.apPwd);
aiObject.setAPTransID(apTransId);
aiObject.setInstant(new GregorianCalendar());
req.setAPInfo(aiObject);
}
final MessageAbstractType.MSSPInfo miObject = mssObjFactory.createMessageAbstractTypeMSSPInfo();
miObject.setMSSPID(mssObjFactory.createMeshMemberType());
req.setMSSPInfo(miObject);
req.setMobileUser(mssObjFactory.createMobileUserType());
return req;
} | public MSSRegistrationReq createRegistrationReq(final String apTransId) {
MSSRegistrationReq req = mssObjFactory.createMSSRegistrationReq();
<DeepExtract>
if (req == null)
throw new IllegalArgumentException("Invalid request (null)");
req.setMajorVersion(Long.valueOf(1));
req.setMinorVersion(Long.valueOf(1));
if (apTransId != null) {
final MessageAbstractType.APInfo aiObject = mssObjFactory.createMessageAbstractTypeAPInfo();
aiObject.setAPID(this.apId);
aiObject.setAPPWD(this.apPwd);
aiObject.setAPTransID(apTransId);
aiObject.setInstant(new GregorianCalendar());
req.setAPInfo(aiObject);
}
final MessageAbstractType.MSSPInfo miObject = mssObjFactory.createMessageAbstractTypeMSSPInfo();
miObject.setMSSPID(mssObjFactory.createMeshMemberType());
req.setMSSPInfo(miObject);
</DeepExtract>
req.setMobileUser(mssObjFactory.createMobileUserType());
return req;
} | laverca | positive | 512 |
public static void showShortToast(CharSequence text) {
showToast(Utils.getContext().getResources().getText(text).toString(), Toast.LENGTH_SHORT);
} | public static void showShortToast(CharSequence text) {
<DeepExtract>
showToast(Utils.getContext().getResources().getText(text).toString(), Toast.LENGTH_SHORT);
</DeepExtract>
} | Componentized | positive | 513 |
public static void numericConcept(String token, ConceptNumeric concept, boolean required, Locale locale, FormField formField) {
String bindName = token;
Element controlNode = getParentNode(formField, locale).createElement(XformBuilder.NAMESPACE_XFORMS, null);
controlNode.setName(XformBuilder.CONTROL_INPUT);
controlNode.setAttribute(null, XformBuilder.ATTRIBUTE_BIND, bindName);
Element bindNode = (Element) bindings.get(bindName);
if (bindNode == null) {
System.out.println("NULL bindNode for: " + bindName);
return null;
}
bindNode.setAttribute(null, XformBuilder.ATTRIBUTE_TYPE, XformBuilder.DATA_TYPE_DECIMAL);
Element labelNode = getParentNode(formField, locale).createElement(XformBuilder.NAMESPACE_XFORMS, null);
labelNode.setName(XformBuilder.NODE_LABEL);
ConceptName name = concept.getBestName(locale);
if (name == null) {
name = concept.getName();
}
labelNode.addChild(Element.TEXT, name.getName());
controlNode.addChild(Element.ELEMENT, labelNode);
addHintNode(labelNode, concept);
XformBuilder.addControl(getParentNode(formField, locale), controlNode);
if (concept instanceof ConceptNumeric) {
ConceptNumeric numericConcept = (ConceptNumeric) concept;
if (numericConcept.isPrecise()) {
Double minInclusive = numericConcept.getLowAbsolute();
Double maxInclusive = numericConcept.getHiAbsolute();
if (!(minInclusive == null && maxInclusive == null)) {
String lower = (minInclusive == null ? "" : FormSchemaFragment.numericToString(minInclusive, numericConcept.isPrecise()));
String upper = (maxInclusive == null ? "" : FormSchemaFragment.numericToString(maxInclusive, numericConcept.isPrecise()));
bindNode.setAttribute(null, XformBuilder.ATTRIBUTE_CONSTRAINT, ". >= " + lower + " and . <= " + upper);
bindNode.setAttribute(null, (XformsUtil.isJavaRosaSaveFormat() ? "jr:constraintMsg" : XformBuilder.ATTRIBUTE_MESSAGE), "value should be between " + lower + " and " + upper + " inclusive");
}
}
}
return controlNode;
} | public static void numericConcept(String token, ConceptNumeric concept, boolean required, Locale locale, FormField formField) {
<DeepExtract>
String bindName = token;
Element controlNode = getParentNode(formField, locale).createElement(XformBuilder.NAMESPACE_XFORMS, null);
controlNode.setName(XformBuilder.CONTROL_INPUT);
controlNode.setAttribute(null, XformBuilder.ATTRIBUTE_BIND, bindName);
Element bindNode = (Element) bindings.get(bindName);
if (bindNode == null) {
System.out.println("NULL bindNode for: " + bindName);
return null;
}
bindNode.setAttribute(null, XformBuilder.ATTRIBUTE_TYPE, XformBuilder.DATA_TYPE_DECIMAL);
Element labelNode = getParentNode(formField, locale).createElement(XformBuilder.NAMESPACE_XFORMS, null);
labelNode.setName(XformBuilder.NODE_LABEL);
ConceptName name = concept.getBestName(locale);
if (name == null) {
name = concept.getName();
}
labelNode.addChild(Element.TEXT, name.getName());
controlNode.addChild(Element.ELEMENT, labelNode);
addHintNode(labelNode, concept);
XformBuilder.addControl(getParentNode(formField, locale), controlNode);
if (concept instanceof ConceptNumeric) {
ConceptNumeric numericConcept = (ConceptNumeric) concept;
if (numericConcept.isPrecise()) {
Double minInclusive = numericConcept.getLowAbsolute();
Double maxInclusive = numericConcept.getHiAbsolute();
if (!(minInclusive == null && maxInclusive == null)) {
String lower = (minInclusive == null ? "" : FormSchemaFragment.numericToString(minInclusive, numericConcept.isPrecise()));
String upper = (maxInclusive == null ? "" : FormSchemaFragment.numericToString(maxInclusive, numericConcept.isPrecise()));
bindNode.setAttribute(null, XformBuilder.ATTRIBUTE_CONSTRAINT, ". >= " + lower + " and . <= " + upper);
bindNode.setAttribute(null, (XformsUtil.isJavaRosaSaveFormat() ? "jr:constraintMsg" : XformBuilder.ATTRIBUTE_MESSAGE), "value should be between " + lower + " and " + upper + " inclusive");
}
}
}
return controlNode;
</DeepExtract>
} | buendia | positive | 514 |
@Override
public void closeEmphasis(SpannableStringBuilder out) {
int len = out.length();
T obj = getLast(out, Italic.class);
int where = out.getSpanStart(obj);
out.removeSpan(obj);
Object[] nestSpans = out.getSpans(where, len, Object.class);
List<NestSpanInfo> spans = new ArrayList<>();
for (Object nestSpan : nestSpans) {
int spanStart = out.getSpanStart(nestSpan);
int spanEnd = out.getSpanEnd(nestSpan);
int spanFlags = out.getSpanFlags(nestSpan);
out.removeSpan(nestSpan);
spans.add(new NestSpanInfo(nestSpan, spanStart, spanEnd, spanFlags));
}
if (where != len) {
out.setSpan(new StyleSpan(Typeface.ITALIC), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
for (NestSpanInfo span : spans) {
out.setSpan(span.span, span.start, span.end, span.flag);
}
} | @Override
public void closeEmphasis(SpannableStringBuilder out) {
<DeepExtract>
int len = out.length();
T obj = getLast(out, Italic.class);
int where = out.getSpanStart(obj);
out.removeSpan(obj);
Object[] nestSpans = out.getSpans(where, len, Object.class);
List<NestSpanInfo> spans = new ArrayList<>();
for (Object nestSpan : nestSpans) {
int spanStart = out.getSpanStart(nestSpan);
int spanEnd = out.getSpanEnd(nestSpan);
int spanFlags = out.getSpanFlags(nestSpan);
out.removeSpan(nestSpan);
spans.add(new NestSpanInfo(nestSpan, spanStart, spanEnd, spanFlags));
}
if (where != len) {
out.setSpan(new StyleSpan(Typeface.ITALIC), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
for (NestSpanInfo span : spans) {
out.setSpan(span.span, span.start, span.end, span.flag);
}
</DeepExtract>
} | kaif-android | positive | 515 |
public static EventAssertOperationBuilder fromEventInfo(EventInfo eventInfo) {
this.data = eventInfo.getEventData();
return this;
} | public static EventAssertOperationBuilder fromEventInfo(EventInfo eventInfo) {
<DeepExtract>
this.data = eventInfo.getEventData();
return this;
</DeepExtract>
} | eventuate-cdc | positive | 516 |
@Override
public void forward() {
this.setStringAttribute(POLARITY, POLARITY_NORMAL);
this.power = this.power;
this.setIntegerAttribute(DUTY_CYCLE, this.power);
this.setStringAttribute(COMMAND, RUN_FOREVER);
} | @Override
public void forward() {
this.setStringAttribute(POLARITY, POLARITY_NORMAL);
<DeepExtract>
this.power = this.power;
this.setIntegerAttribute(DUTY_CYCLE, this.power);
</DeepExtract>
this.setStringAttribute(COMMAND, RUN_FOREVER);
} | ev3dev-lang-java | positive | 517 |
private void addMethodDesc(final String desc) {
switch(Type.getReturnType(desc).getSort()) {
case Type.ARRAY:
addType(Type.getReturnType(desc).getElementType());
break;
case Type.OBJECT:
addName(Type.getReturnType(desc).getInternalName());
break;
}
Type[] types = Type.getArgumentTypes(desc);
for (int i = 0; i < types.length; i++) {
addType(types[i]);
}
} | private void addMethodDesc(final String desc) {
<DeepExtract>
switch(Type.getReturnType(desc).getSort()) {
case Type.ARRAY:
addType(Type.getReturnType(desc).getElementType());
break;
case Type.OBJECT:
addName(Type.getReturnType(desc).getInternalName());
break;
}
</DeepExtract>
Type[] types = Type.getArgumentTypes(desc);
for (int i = 0; i < types.length; i++) {
addType(types[i]);
}
} | vinja | positive | 518 |
private void createArtworkRequestQueue(final boolean fetchAlbums, final boolean fetchArtists) {
mArtworkRequestQueue.clear();
if (fetchAlbums) {
List<AlbumModel> albums = MusicLibraryHelper.getAllAlbums(getApplicationContext());
for (AlbumModel album : albums) {
mArtworkRequestQueue.add(new ArtworkRequestModel(album));
}
}
if (fetchArtists) {
List<ArtistModel> artists = MusicLibraryHelper.getAllArtists(false, getApplicationContext());
for (ArtistModel artist : artists) {
mArtworkRequestQueue.add(new ArtworkRequestModel(artist));
}
}
if (BuildConfig.DEBUG) {
Log.v(TAG, "Bulkloading started with: " + mArtworkRequestQueue.size());
}
mSumArtworkRequests = mArtworkRequestQueue.size();
mBuilder.setContentTitle(getString(R.string.downloader_notification_remaining_images));
if (mArtworkRequestQueue.isEmpty()) {
finishedLoading();
} else {
performNextRequest();
}
} | private void createArtworkRequestQueue(final boolean fetchAlbums, final boolean fetchArtists) {
mArtworkRequestQueue.clear();
if (fetchAlbums) {
List<AlbumModel> albums = MusicLibraryHelper.getAllAlbums(getApplicationContext());
for (AlbumModel album : albums) {
mArtworkRequestQueue.add(new ArtworkRequestModel(album));
}
}
if (fetchArtists) {
List<ArtistModel> artists = MusicLibraryHelper.getAllArtists(false, getApplicationContext());
for (ArtistModel artist : artists) {
mArtworkRequestQueue.add(new ArtworkRequestModel(artist));
}
}
<DeepExtract>
if (BuildConfig.DEBUG) {
Log.v(TAG, "Bulkloading started with: " + mArtworkRequestQueue.size());
}
mSumArtworkRequests = mArtworkRequestQueue.size();
mBuilder.setContentTitle(getString(R.string.downloader_notification_remaining_images));
if (mArtworkRequestQueue.isEmpty()) {
finishedLoading();
} else {
performNextRequest();
}
</DeepExtract>
} | odyssey | positive | 519 |
public static Drawable byteToDrawable(byte[] b) {
return byteToBitmap(b) == null ? null : new BitmapDrawable(byteToBitmap(b));
} | public static Drawable byteToDrawable(byte[] b) {
<DeepExtract>
return byteToBitmap(b) == null ? null : new BitmapDrawable(byteToBitmap(b));
</DeepExtract>
} | Mantis | positive | 520 |
@Override
public boolean hasNext() {
return nextIndex > 0;
} | @Override
public boolean hasNext() {
<DeepExtract>
return nextIndex > 0;
</DeepExtract>
} | CoFHTweaks | positive | 521 |
public void init(Cursor c) {
if (mAdapter == null) {
return;
}
if (mActivity.isFinishing() && c != null) {
c.close();
c = null;
}
if (c != mActivity.mQueryCursor) {
mActivity.mQueryCursor = c;
super.changeCursor(c);
}
if (mQueryCursor == null) {
setListAdapter(null);
return;
}
} | public void init(Cursor c) {
if (mAdapter == null) {
return;
}
<DeepExtract>
if (mActivity.isFinishing() && c != null) {
c.close();
c = null;
}
if (c != mActivity.mQueryCursor) {
mActivity.mQueryCursor = c;
super.changeCursor(c);
}
</DeepExtract>
if (mQueryCursor == null) {
setListAdapter(null);
return;
}
} | android_packages_apps_apolloMod | positive | 522 |
@Override
protected void onPause() {
unregisterReceiver(airplaneModeChangedReceiver);
unregisterReceiver(updateChartReceiver);
unregisterReceiver(batteryChangedReceiver);
Log.d(TAG, "cancelDimScreenTask");
if (dimScreenTask != null) {
Log.d(TAG, "dimScreenTask != null");
dimScreenTask.cancel(true);
if (!dimScreenTask.isScreenDimmed() && (isUserLeaving || isFinishing())) {
Log.d(TAG, "!screenDimmed && isUserLeaving");
setToast(R.string.warning_dim_sleep_mode_can_only_occur_on_the_sleep_screen_);
}
}
if (mServiceBound.compareAndSet(true, false)) {
unbindService(serviceConnection);
}
isUserLeaving = false;
super.onPause();
} | @Override
protected void onPause() {
unregisterReceiver(airplaneModeChangedReceiver);
unregisterReceiver(updateChartReceiver);
unregisterReceiver(batteryChangedReceiver);
<DeepExtract>
Log.d(TAG, "cancelDimScreenTask");
if (dimScreenTask != null) {
Log.d(TAG, "dimScreenTask != null");
dimScreenTask.cancel(true);
if (!dimScreenTask.isScreenDimmed() && (isUserLeaving || isFinishing())) {
Log.d(TAG, "!screenDimmed && isUserLeaving");
setToast(R.string.warning_dim_sleep_mode_can_only_occur_on_the_sleep_screen_);
}
}
</DeepExtract>
if (mServiceBound.compareAndSet(true, false)) {
unbindService(serviceConnection);
}
isUserLeaving = false;
super.onPause();
} | ElectricSleep | positive | 523 |
@Test
public void testVeienVn() {
assertEquals(cleaner.clean("grefsenvn. 132"), cleaner.clean("grefsenveien 132"));
} | @Test
public void testVeienVn() {
<DeepExtract>
assertEquals(cleaner.clean("grefsenvn. 132"), cleaner.clean("grefsenveien 132"));
</DeepExtract>
} | duke | positive | 524 |
@Override
public void write(int b) throws IOException {
if (closed)
throw new IOException("Cannot read from stream anymore. It has been closed");
if (available() < 1)
flush();
buf[curr++] = (byte) b;
} | @Override
public void write(int b) throws IOException {
<DeepExtract>
if (closed)
throw new IOException("Cannot read from stream anymore. It has been closed");
</DeepExtract>
if (available() < 1)
flush();
buf[curr++] = (byte) b;
} | mango | positive | 525 |
@Test
public void canWorkWithProcessViewOfModel3c() throws IOException {
ServiceSpecification mdsl = new MDSLResource(getTestResource("flowtest3c-exclusivechoiceviacommand-implicitmerge.mdsl")).getServiceSpecification();
MDSL2GeneratorModelConverter converter = new MDSL2GeneratorModelConverter(mdsl);
MDSLGeneratorModel mdslGenModel = converter.convert();
if (MDSLLogger.logLevel < 2) {
return;
}
String flowDump = mdslGenModel.getOrchestrationFlows().get(0).toString();
System.out.println("----------------------------------------------------------------------------");
System.out.print(flowDump);
System.out.println("----------------------------------------------------------------------------");
Process processViewOnGenModel = mdslGenModel.getOrchestrationFlows().get(0).processView();
PathCollection pc = processViewOnGenModel.getAllPaths();
if (MDSLLogger.logLevel < 2) {
return;
}
System.out.println("----------------------------------------------------------------------------");
if (pc != null)
System.out.println(pc.toString());
else
MDSLLogger.reportWarning("Empty path collection.");
System.out.println("----------------------------------------------------------------------------");
assertEquals("FlowTest3c", mdslGenModel.getApiName());
assertEquals(2, pc.size());
assertEquals(9, processViewOnGenModel.numberOfNodes());
assertEquals(7, processViewOnGenModel.numberOfEdges());
assertEquals(4, pc.getPath(0).length());
assertEquals(3, pc.getPath(1).length());
assertEquals("FlowInitiated", pc.getPath(0).getEventAt(0));
assertEquals("FlowStep1", pc.getPath(0).getCommandAt(0));
assertEquals("FlowStep1CompletedOptionA", pc.getPath(0).getEventAt(1));
assertEquals("FlowStep3", pc.getPath(0).getCommandAt(1));
assertEquals("FlowStep3Completed", pc.getPath(0).getEventAt(2));
assertEquals("FlowStep4", pc.getPath(0).getCommandAt(2));
assertEquals("FlowTerminated", pc.getPath(0).getEventAt(3));
assertEquals("done", pc.getPath(0).getCommandAt(3));
assertEquals("FlowStep2Completed", pc.getPath(1).getEventAt(1));
assertEquals("FlowStep4", pc.getPath(1).getCommandAt(1));
assertEquals("FlowTerminated", pc.getPath(1).getEventAt(2));
assertEquals("done", pc.getPath(1).getCommandAt(2));
} | @Test
public void canWorkWithProcessViewOfModel3c() throws IOException {
ServiceSpecification mdsl = new MDSLResource(getTestResource("flowtest3c-exclusivechoiceviacommand-implicitmerge.mdsl")).getServiceSpecification();
MDSL2GeneratorModelConverter converter = new MDSL2GeneratorModelConverter(mdsl);
MDSLGeneratorModel mdslGenModel = converter.convert();
if (MDSLLogger.logLevel < 2) {
return;
}
String flowDump = mdslGenModel.getOrchestrationFlows().get(0).toString();
System.out.println("----------------------------------------------------------------------------");
System.out.print(flowDump);
System.out.println("----------------------------------------------------------------------------");
Process processViewOnGenModel = mdslGenModel.getOrchestrationFlows().get(0).processView();
PathCollection pc = processViewOnGenModel.getAllPaths();
<DeepExtract>
if (MDSLLogger.logLevel < 2) {
return;
}
System.out.println("----------------------------------------------------------------------------");
if (pc != null)
System.out.println(pc.toString());
else
MDSLLogger.reportWarning("Empty path collection.");
System.out.println("----------------------------------------------------------------------------");
</DeepExtract>
assertEquals("FlowTest3c", mdslGenModel.getApiName());
assertEquals(2, pc.size());
assertEquals(9, processViewOnGenModel.numberOfNodes());
assertEquals(7, processViewOnGenModel.numberOfEdges());
assertEquals(4, pc.getPath(0).length());
assertEquals(3, pc.getPath(1).length());
assertEquals("FlowInitiated", pc.getPath(0).getEventAt(0));
assertEquals("FlowStep1", pc.getPath(0).getCommandAt(0));
assertEquals("FlowStep1CompletedOptionA", pc.getPath(0).getEventAt(1));
assertEquals("FlowStep3", pc.getPath(0).getCommandAt(1));
assertEquals("FlowStep3Completed", pc.getPath(0).getEventAt(2));
assertEquals("FlowStep4", pc.getPath(0).getCommandAt(2));
assertEquals("FlowTerminated", pc.getPath(0).getEventAt(3));
assertEquals("done", pc.getPath(0).getCommandAt(3));
assertEquals("FlowStep2Completed", pc.getPath(1).getEventAt(1));
assertEquals("FlowStep4", pc.getPath(1).getCommandAt(1));
assertEquals("FlowTerminated", pc.getPath(1).getEventAt(2));
assertEquals("done", pc.getPath(1).getCommandAt(2));
} | MDSL-Specification | positive | 526 |
public void ping() throws org.apache.thrift.TException {
ping_args args = new ping_args();
sendBase("ping", args);
ping_result result = new ping_result();
receiveBase(result, "ping");
return;
} | public void ping() throws org.apache.thrift.TException {
ping_args args = new ping_args();
sendBase("ping", args);
<DeepExtract>
ping_result result = new ping_result();
receiveBase(result, "ping");
return;
</DeepExtract>
} | Thrift-Connection-Pool | positive | 527 |
@Override
public String toString() {
return position + "-" + type;
} | @Override
public String toString() {
<DeepExtract>
return position + "-" + type;
</DeepExtract>
} | JointER | positive | 528 |
public void actionPerformed(java.awt.event.ActionEvent evt) {
} | public void actionPerformed(java.awt.event.ActionEvent evt) {
<DeepExtract>
</DeepExtract>
} | CODEX | positive | 529 |
@Subscribe
public void handleScapyConnectedEventEngine(ScapyClientConnectedEvent event) {
menuControllerEngine.initTemplateMenu();
} | @Subscribe
public void handleScapyConnectedEventEngine(ScapyClientConnectedEvent event) {
<DeepExtract>
menuControllerEngine.initTemplateMenu();
</DeepExtract>
} | trex-packet-editor | positive | 530 |
private static boolean listQuads(ArrayList<XYZO> a, ArrayList<XYZO> b, ArrayList<XYZO> c, ArrayList<XYZO> d, File f) {
if ((a == null) || (f == null))
return false;
try {
pw = new PrintWriter(new FileWriter(f), true);
} catch (IOException ioe) {
return false;
}
if ((a == null) || (pw == null))
return;
for (int i = 0; i < a.size(); i++) {
XYZO o = a.get(i);
double x = o.getX();
double y = o.getY();
double z = o.getZ();
int op = o.getO();
String s = U.fwi(i, 6) + U.fwd(x, 20, 8) + U.fwd(y, 20, 8) + U.fwd(z, 20, 8) + U.fwi(op, 8);
pw.println(s + interpretQuad(op % 1000));
}
if ((b == null) || (pw == null))
return;
for (int i = 0; i < b.size(); i++) {
XYZO o = b.get(i);
double x = o.getX();
double y = o.getY();
double z = o.getZ();
int op = o.getO();
String s = U.fwi(i, 6) + U.fwd(x, 20, 8) + U.fwd(y, 20, 8) + U.fwd(z, 20, 8) + U.fwi(op, 8);
pw.println(s + interpretQuad(op % 1000));
}
if ((c == null) || (pw == null))
return;
for (int i = 0; i < c.size(); i++) {
XYZO o = c.get(i);
double x = o.getX();
double y = o.getY();
double z = o.getZ();
int op = o.getO();
String s = U.fwi(i, 6) + U.fwd(x, 20, 8) + U.fwd(y, 20, 8) + U.fwd(z, 20, 8) + U.fwi(op, 8);
pw.println(s + interpretQuad(op % 1000));
}
pw.close();
return true;
} | private static boolean listQuads(ArrayList<XYZO> a, ArrayList<XYZO> b, ArrayList<XYZO> c, ArrayList<XYZO> d, File f) {
if ((a == null) || (f == null))
return false;
try {
pw = new PrintWriter(new FileWriter(f), true);
} catch (IOException ioe) {
return false;
}
if ((a == null) || (pw == null))
return;
for (int i = 0; i < a.size(); i++) {
XYZO o = a.get(i);
double x = o.getX();
double y = o.getY();
double z = o.getZ();
int op = o.getO();
String s = U.fwi(i, 6) + U.fwd(x, 20, 8) + U.fwd(y, 20, 8) + U.fwd(z, 20, 8) + U.fwi(op, 8);
pw.println(s + interpretQuad(op % 1000));
}
if ((b == null) || (pw == null))
return;
for (int i = 0; i < b.size(); i++) {
XYZO o = b.get(i);
double x = o.getX();
double y = o.getY();
double z = o.getZ();
int op = o.getO();
String s = U.fwi(i, 6) + U.fwd(x, 20, 8) + U.fwd(y, 20, 8) + U.fwd(z, 20, 8) + U.fwi(op, 8);
pw.println(s + interpretQuad(op % 1000));
}
<DeepExtract>
if ((c == null) || (pw == null))
return;
for (int i = 0; i < c.size(); i++) {
XYZO o = c.get(i);
double x = o.getX();
double y = o.getY();
double z = o.getZ();
int op = o.getO();
String s = U.fwi(i, 6) + U.fwd(x, 20, 8) + U.fwd(y, 20, 8) + U.fwd(z, 20, 8) + U.fwi(op, 8);
pw.println(s + interpretQuad(op % 1000));
}
</DeepExtract>
pw.close();
return true;
} | BeamFour | positive | 531 |
public Coin plus(final Coin value) {
return new Coin(LongMath.checkedAdd(this.value, value.value));
} | public Coin plus(final Coin value) {
<DeepExtract>
return new Coin(LongMath.checkedAdd(this.value, value.value));
</DeepExtract>
} | ulordj-thin | positive | 532 |
public void validateForm(String firstName, String lastName, String email, String userName, String password, String confirmPassword) {
clearForm();
firstNameField.sendKeys(firstName);
lastNameField.sendKeys(lastName);
emailField.sendKeys(email);
userNameField.sendKeys(userName);
passwordField.sendKeys(password);
passwordConfirmationField.sendKeys(confirmPassword);
registerButton.click();
} | public void validateForm(String firstName, String lastName, String email, String userName, String password, String confirmPassword) {
<DeepExtract>
clearForm();
firstNameField.sendKeys(firstName);
lastNameField.sendKeys(lastName);
emailField.sendKeys(email);
userNameField.sendKeys(userName);
passwordField.sendKeys(password);
passwordConfirmationField.sendKeys(confirmPassword);
registerButton.click();
</DeepExtract>
} | product-iots | positive | 533 |
public void setColorMap(Palette palette) {
this.colors.clear();
this.colors.addAll(Arrays.asList(palette.getColors()));
setValues(Arrays.asList(palette.getValues()));
} | public void setColorMap(Palette palette) {
<DeepExtract>
this.colors.clear();
this.colors.addAll(Arrays.asList(palette.getColors()));
setValues(Arrays.asList(palette.getValues()));
</DeepExtract>
} | DicomViewer | positive | 534 |
public Criteria andCreate_timeGreaterThan(Date value) {
if (value == null) {
throw new RuntimeException("Value for " + "create_time" + " cannot be null");
}
criteria.add(new Criterion("create_time >", value));
return (Criteria) this;
} | public Criteria andCreate_timeGreaterThan(Date value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "create_time" + " cannot be null");
}
criteria.add(new Criterion("create_time >", value));
</DeepExtract>
return (Criteria) this;
} | SpringBootLearning | positive | 535 |
public RetCode tema(int startIdx, int endIdx, double[] inReal, int optInTimePeriod, MInteger outBegIdx, MInteger outNBElement, double[] outReal) {
MInteger firstEMABegIdx = new MInteger();
MInteger firstEMANbElement = new MInteger();
MInteger secondEMABegIdx = new MInteger();
MInteger secondEMANbElement = new MInteger();
MInteger thirdEMABegIdx = new MInteger();
MInteger thirdEMANbElement = new MInteger();
if (startIdx < 0)
return RetCode.OutOfRangeStartIndex;
if ((endIdx < 0) || (endIdx < startIdx))
return RetCode.OutOfRangeEndIndex;
if ((int) optInTimePeriod == (Integer.MIN_VALUE))
optInTimePeriod = 30;
else if (((int) optInTimePeriod < 2) || ((int) optInTimePeriod > 100000))
return RetCode.BadParam;
outNBElement.value = 0;
outBegIdx.value = 0;
if ((int) optInTimePeriod == (Integer.MIN_VALUE))
optInTimePeriod = 30;
else if (((int) optInTimePeriod < 2) || ((int) optInTimePeriod > 100000))
lookbackEMA = -1;
return optInTimePeriod - 1 + (this.unstablePeriod[FuncUnstId.Ema.ordinal()]);
lookbackTotal = lookbackEMA * 3;
if (startIdx < lookbackTotal)
startIdx = lookbackTotal;
if (startIdx > endIdx)
return RetCode.Success;
tempInt = lookbackTotal + (endIdx - startIdx) + 1;
firstEMA = new double[tempInt];
k = ((double) 2.0 / ((double) (optInTimePeriod + 1)));
double tempReal, prevMA;
int i, today, outIdx, lookbackTotal;
lookbackTotal = emaLookback(optInTimePeriod);
if (startIdx - (lookbackEMA * 2) < lookbackTotal)
startIdx - (lookbackEMA * 2) = lookbackTotal;
if (startIdx - (lookbackEMA * 2) > endIdx) {
firstEMABegIdx.value = 0;
firstEMANbElement.value = 0;
retCode = RetCode.Success;
}
firstEMABegIdx.value = startIdx - (lookbackEMA * 2);
if ((this.compatibility) == Compatibility.Default) {
today = startIdx - (lookbackEMA * 2) - lookbackTotal;
i = optInTimePeriod;
tempReal = 0.0;
while (i-- > 0) tempReal += inReal[today++];
prevMA = tempReal / optInTimePeriod;
} else {
prevMA = inReal[0];
today = 1;
}
while (today <= startIdx - (lookbackEMA * 2)) prevMA = ((inReal[today++] - prevMA) * k) + prevMA;
firstEMA[0] = prevMA;
outIdx = 1;
while (today <= endIdx) {
prevMA = ((inReal[today++] - prevMA) * k) + prevMA;
firstEMA[outIdx++] = prevMA;
}
firstEMANbElement.value = outIdx;
return RetCode.Success;
if ((retCode != RetCode.Success) || (firstEMANbElement.value == 0)) {
return retCode;
}
secondEMA = new double[firstEMANbElement.value];
double tempReal, prevMA;
int i, today, outIdx, lookbackTotal;
lookbackTotal = emaLookback(optInTimePeriod);
if (0 < lookbackTotal)
0 = lookbackTotal;
if (0 > firstEMANbElement.value - 1) {
secondEMABegIdx.value = 0;
secondEMANbElement.value = 0;
retCode = RetCode.Success;
}
secondEMABegIdx.value = 0;
if ((this.compatibility) == Compatibility.Default) {
today = 0 - lookbackTotal;
i = optInTimePeriod;
tempReal = 0.0;
while (i-- > 0) tempReal += firstEMA[today++];
prevMA = tempReal / optInTimePeriod;
} else {
prevMA = firstEMA[0];
today = 1;
}
while (today <= 0) prevMA = ((firstEMA[today++] - prevMA) * k) + prevMA;
secondEMA[0] = prevMA;
outIdx = 1;
while (today <= firstEMANbElement.value - 1) {
prevMA = ((firstEMA[today++] - prevMA) * k) + prevMA;
secondEMA[outIdx++] = prevMA;
}
secondEMANbElement.value = outIdx;
return RetCode.Success;
if ((retCode != RetCode.Success) || (secondEMANbElement.value == 0)) {
return retCode;
}
double tempReal, prevMA;
int i, today, outIdx, lookbackTotal;
lookbackTotal = emaLookback(optInTimePeriod);
if (0 < lookbackTotal)
0 = lookbackTotal;
if (0 > secondEMANbElement.value - 1) {
thirdEMABegIdx.value = 0;
thirdEMANbElement.value = 0;
retCode = RetCode.Success;
}
thirdEMABegIdx.value = 0;
if ((this.compatibility) == Compatibility.Default) {
today = 0 - lookbackTotal;
i = optInTimePeriod;
tempReal = 0.0;
while (i-- > 0) tempReal += secondEMA[today++];
prevMA = tempReal / optInTimePeriod;
} else {
prevMA = secondEMA[0];
today = 1;
}
while (today <= 0) prevMA = ((secondEMA[today++] - prevMA) * k) + prevMA;
outReal[0] = prevMA;
outIdx = 1;
while (today <= secondEMANbElement.value - 1) {
prevMA = ((secondEMA[today++] - prevMA) * k) + prevMA;
outReal[outIdx++] = prevMA;
}
thirdEMANbElement.value = outIdx;
return RetCode.Success;
if ((retCode != RetCode.Success) || (thirdEMANbElement.value == 0)) {
return retCode;
}
firstEMAIdx = thirdEMABegIdx.value + secondEMABegIdx.value;
secondEMAIdx = thirdEMABegIdx.value;
outBegIdx.value = firstEMAIdx + firstEMABegIdx.value;
outIdx = 0;
while (outIdx < thirdEMANbElement.value) {
outReal[outIdx] += (3.0 * firstEMA[firstEMAIdx++]) - (3.0 * secondEMA[secondEMAIdx++]);
outIdx++;
}
outNBElement.value = outIdx;
return RetCode.Success;
} | public RetCode tema(int startIdx, int endIdx, double[] inReal, int optInTimePeriod, MInteger outBegIdx, MInteger outNBElement, double[] outReal) {
MInteger firstEMABegIdx = new MInteger();
MInteger firstEMANbElement = new MInteger();
MInteger secondEMABegIdx = new MInteger();
MInteger secondEMANbElement = new MInteger();
MInteger thirdEMABegIdx = new MInteger();
MInteger thirdEMANbElement = new MInteger();
if (startIdx < 0)
return RetCode.OutOfRangeStartIndex;
if ((endIdx < 0) || (endIdx < startIdx))
return RetCode.OutOfRangeEndIndex;
if ((int) optInTimePeriod == (Integer.MIN_VALUE))
optInTimePeriod = 30;
else if (((int) optInTimePeriod < 2) || ((int) optInTimePeriod > 100000))
return RetCode.BadParam;
outNBElement.value = 0;
outBegIdx.value = 0;
if ((int) optInTimePeriod == (Integer.MIN_VALUE))
optInTimePeriod = 30;
else if (((int) optInTimePeriod < 2) || ((int) optInTimePeriod > 100000))
lookbackEMA = -1;
return optInTimePeriod - 1 + (this.unstablePeriod[FuncUnstId.Ema.ordinal()]);
lookbackTotal = lookbackEMA * 3;
if (startIdx < lookbackTotal)
startIdx = lookbackTotal;
if (startIdx > endIdx)
return RetCode.Success;
tempInt = lookbackTotal + (endIdx - startIdx) + 1;
firstEMA = new double[tempInt];
k = ((double) 2.0 / ((double) (optInTimePeriod + 1)));
double tempReal, prevMA;
int i, today, outIdx, lookbackTotal;
lookbackTotal = emaLookback(optInTimePeriod);
if (startIdx - (lookbackEMA * 2) < lookbackTotal)
startIdx - (lookbackEMA * 2) = lookbackTotal;
if (startIdx - (lookbackEMA * 2) > endIdx) {
firstEMABegIdx.value = 0;
firstEMANbElement.value = 0;
retCode = RetCode.Success;
}
firstEMABegIdx.value = startIdx - (lookbackEMA * 2);
if ((this.compatibility) == Compatibility.Default) {
today = startIdx - (lookbackEMA * 2) - lookbackTotal;
i = optInTimePeriod;
tempReal = 0.0;
while (i-- > 0) tempReal += inReal[today++];
prevMA = tempReal / optInTimePeriod;
} else {
prevMA = inReal[0];
today = 1;
}
while (today <= startIdx - (lookbackEMA * 2)) prevMA = ((inReal[today++] - prevMA) * k) + prevMA;
firstEMA[0] = prevMA;
outIdx = 1;
while (today <= endIdx) {
prevMA = ((inReal[today++] - prevMA) * k) + prevMA;
firstEMA[outIdx++] = prevMA;
}
firstEMANbElement.value = outIdx;
return RetCode.Success;
if ((retCode != RetCode.Success) || (firstEMANbElement.value == 0)) {
return retCode;
}
secondEMA = new double[firstEMANbElement.value];
double tempReal, prevMA;
int i, today, outIdx, lookbackTotal;
lookbackTotal = emaLookback(optInTimePeriod);
if (0 < lookbackTotal)
0 = lookbackTotal;
if (0 > firstEMANbElement.value - 1) {
secondEMABegIdx.value = 0;
secondEMANbElement.value = 0;
retCode = RetCode.Success;
}
secondEMABegIdx.value = 0;
if ((this.compatibility) == Compatibility.Default) {
today = 0 - lookbackTotal;
i = optInTimePeriod;
tempReal = 0.0;
while (i-- > 0) tempReal += firstEMA[today++];
prevMA = tempReal / optInTimePeriod;
} else {
prevMA = firstEMA[0];
today = 1;
}
while (today <= 0) prevMA = ((firstEMA[today++] - prevMA) * k) + prevMA;
secondEMA[0] = prevMA;
outIdx = 1;
while (today <= firstEMANbElement.value - 1) {
prevMA = ((firstEMA[today++] - prevMA) * k) + prevMA;
secondEMA[outIdx++] = prevMA;
}
secondEMANbElement.value = outIdx;
return RetCode.Success;
if ((retCode != RetCode.Success) || (secondEMANbElement.value == 0)) {
return retCode;
}
<DeepExtract>
double tempReal, prevMA;
int i, today, outIdx, lookbackTotal;
lookbackTotal = emaLookback(optInTimePeriod);
if (0 < lookbackTotal)
0 = lookbackTotal;
if (0 > secondEMANbElement.value - 1) {
thirdEMABegIdx.value = 0;
thirdEMANbElement.value = 0;
retCode = RetCode.Success;
}
thirdEMABegIdx.value = 0;
if ((this.compatibility) == Compatibility.Default) {
today = 0 - lookbackTotal;
i = optInTimePeriod;
tempReal = 0.0;
while (i-- > 0) tempReal += secondEMA[today++];
prevMA = tempReal / optInTimePeriod;
} else {
prevMA = secondEMA[0];
today = 1;
}
while (today <= 0) prevMA = ((secondEMA[today++] - prevMA) * k) + prevMA;
outReal[0] = prevMA;
outIdx = 1;
while (today <= secondEMANbElement.value - 1) {
prevMA = ((secondEMA[today++] - prevMA) * k) + prevMA;
outReal[outIdx++] = prevMA;
}
thirdEMANbElement.value = outIdx;
return RetCode.Success;
</DeepExtract>
if ((retCode != RetCode.Success) || (thirdEMANbElement.value == 0)) {
return retCode;
}
firstEMAIdx = thirdEMABegIdx.value + secondEMABegIdx.value;
secondEMAIdx = thirdEMABegIdx.value;
outBegIdx.value = firstEMAIdx + firstEMABegIdx.value;
outIdx = 0;
while (outIdx < thirdEMANbElement.value) {
outReal[outIdx] += (3.0 * firstEMA[firstEMAIdx++]) - (3.0 * secondEMA[secondEMAIdx++]);
outIdx++;
}
outNBElement.value = outIdx;
return RetCode.Success;
} | TA-Lib | positive | 536 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.