java.util.Objects Java Examples
The following examples show how to use
java.util.Objects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Deposit.java From teku with Apache License 2.0 | 7 votes |
@Override public boolean equals(Object obj) { if (Objects.isNull(obj)) { return false; } if (this == obj) { return true; } if (!(obj instanceof Deposit)) { return false; } Deposit other = (Deposit) obj; return Objects.equals(this.getProof(), other.getProof()) && Objects.equals(this.getData(), other.getData()); }
Example #2
Source File: IntPipeline.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public final <U> Stream<U> mapToObj(IntFunction<? extends U> mapper) { Objects.requireNonNull(mapper); return new ReferencePipeline.StatelessOp<Integer, U>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Integer> opWrapSink(int flags, Sink<U> sink) { return new Sink.ChainedInt<U>(sink) { @Override public void accept(int t) { downstream.accept(mapper.apply(t)); } }; } }; }
Example #3
Source File: AnnotationSupport.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Finds and returns all associated annotations matching the given class. * * The order of the elements in the array returned depends on the iteration * order of the provided maps. Specifically, the directly present annotations * come before the indirectly present annotations if and only if the * directly present annotations come before the indirectly present * annotations in the relevant map. * * @param declaredAnnotations the declared annotations indexed by their types * @param decl the class declaration on which to search for annotations * @param annoClass the type of annotation to search for * * @return an array of instances of {@code annoClass} or an empty array if none were found. */ public static <A extends Annotation> A[] getAssociatedAnnotations( Map<Class<? extends Annotation>, Annotation> declaredAnnotations, Class<?> decl, Class<A> annoClass) { Objects.requireNonNull(decl); // Search declared A[] result = getDirectlyAndIndirectlyPresent(declaredAnnotations, annoClass); // Search inherited if(AnnotationType.getInstance(annoClass).isInherited()) { Class<?> superDecl = decl.getSuperclass(); while (result.length == 0 && superDecl != null) { result = getDirectlyAndIndirectlyPresent(LANG_ACCESS.getDeclaredAnnotationMap(superDecl), annoClass); superDecl = superDecl.getSuperclass(); } } return result; }
Example #4
Source File: RpcLocker.java From sumk with Apache License 2.0 | 6 votes |
public void wakeup(RpcResult result) { long receiveTime = System.currentTimeMillis(); Objects.requireNonNull(result, "result cannot be null"); if (this.isWaked()) { return; } if (!this.result.compareAndSet(null, result)) { return; } Thread thread = awaitThread.getAndSet(null); if (thread != null) { LockSupport.unpark(thread); } if (this.callback != null) { try { callback.accept(result); } catch (Throwable e) { Log.printStack("sumk.rpc", e); } } RpcLogs.clientLog(this.url, this.req, result, receiveTime); }
Example #5
Source File: DiagnosticDataSummary.java From director-sdk with Apache License 2.0 | 6 votes |
@Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DiagnosticDataSummary diagnosticDataSummary = (DiagnosticDataSummary) o; return Objects.equals(this.status, diagnosticDataSummary.status) && Objects.equals(this.collectionTime, diagnosticDataSummary.collectionTime) && Objects.equals(this.localFilePath, diagnosticDataSummary.localFilePath) && Objects.equals(this.details, diagnosticDataSummary.details) && Objects.equals(this.diagnosticDataCollected, diagnosticDataSummary.diagnosticDataCollected) && Objects.equals(this.diagnosticDataDownloaded, diagnosticDataSummary.diagnosticDataDownloaded) && Objects.equals(this.clouderaManagerLogsDownloaded, diagnosticDataSummary.clouderaManagerLogsDownloaded); }
Example #6
Source File: RBlastSmilesGenerator.java From ReactionDecoder with GNU Lesser General Public License v3.0 | 6 votes |
/** * Creates a string for the charge of atom <code>a</code>. If the charge is * 1 + is returned if it is -1 - is returned. The positive values all have + * in front of them. * * @return string representing the charge on <code>a</code> */ private String generateChargeString(IAtom a) { int charge = Objects.equals(a.getFormalCharge(), UNSET) ? 0 : a.getFormalCharge(); StringBuilder buffer = new StringBuilder(3); if (charge > 0) { //Positive buffer.append('+'); if (charge > 1) { buffer.append(charge); } } else if (charge < 0) { //Negative if (charge == -1) { buffer.append('-'); } else { buffer.append(charge); } } return buffer.toString(); }
Example #7
Source File: DeferredSubscription.java From reactive-streams-commons with Apache License 2.0 | 6 votes |
/** * Sets the Subscription once but does not request anything. * @param s the Subscription to set * @return true if successful, false if the current subscription is not null */ protected final boolean setWithoutRequesting(Subscription s) { Objects.requireNonNull(s, "s"); for (;;) { Subscription a = this.s; if (a == SubscriptionHelper.cancelled()) { s.cancel(); return false; } if (a != null) { s.cancel(); SubscriptionHelper.reportSubscriptionSet(); return false; } if (S.compareAndSet(this, null, s)) { return true; } } }
Example #8
Source File: ResearchSubjectStatus.java From FHIR with Apache License 2.0 | 5 votes |
@Override public int hashCode() { int result = hashCode; if (result == 0) { result = Objects.hash(id, extension, value); hashCode = result; } return result; }
Example #9
Source File: FormatToExpression.java From Digital with GNU General Public License v3.0 | 5 votes |
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; FormatToExpression that = (FormatToExpression) o; return Objects.equals(orString, that.orString) && Objects.equals(andString, that.andString) && Objects.equals(falseString, that.falseString) && Objects.equals(trueString, that.trueString) && Objects.equals(xorString, that.xorString) && Objects.equals(notString, that.notString) && Objects.equals(getEqual(), that.getEqual()); }
Example #10
Source File: NettyHttpResponse.java From netstrap with Apache License 2.0 | 5 votes |
/** * 写数据 */ private void writeFlush() { //添加数据长度响应头 int length = Objects.isNull(getBody()) ? 0 : getBody().getBytes().length; response.headers().add(CONTENT_LENGTH, length); ChannelFuture future = channel.writeAndFlush(response); if (!isKeepAlive()) { future.addListener(ChannelFutureListener.CLOSE); } //只能写一次。 setWritable(false); }
Example #11
Source File: CodecContext.java From java-ilp-core with Apache License 2.0 | 5 votes |
/** * Register a converter associated to the supplied {@code type}. * * @param type An instance of {link Class} of type {@link T}. * @param converter An instance of {@link Codec}. * @param <T> An instance of {@link T}. * * @return A {@link CodecContext} for the supplied {@code type}. */ public <T> CodecContext register(final Class<? extends T> type, final Codec<T> converter) { Objects.requireNonNull(type); Objects.requireNonNull(converter); this.codecs.put(type, converter); if (converter instanceof InterledgerPacketCodec<?>) { InterledgerPacketCodec<?> commandTypeConverter = (InterledgerPacketCodec) converter; this.packetCodecs.put(commandTypeConverter.getTypeId(), type); } return this; }
Example #12
Source File: ListASRAnnotationSetsResponse.java From alexa-apis-for-java with Apache License 2.0 | 5 votes |
@Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ListASRAnnotationSetsResponse v1SkillAsrAnnotationSetsListASRAnnotationSetsResponse = (ListASRAnnotationSetsResponse) o; return Objects.equals(this.annotationSets, v1SkillAsrAnnotationSetsListASRAnnotationSetsResponse.annotationSets) && Objects.equals(this.paginationContext, v1SkillAsrAnnotationSetsListASRAnnotationSetsResponse.paginationContext); }
Example #13
Source File: WallpostStat.java From vk-java-sdk with MIT License | 5 votes |
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; WallpostStat wallpostStat = (WallpostStat) o; return Objects.equals(joinGroup, wallpostStat.joinGroup) && Objects.equals(reachSubscribers, wallpostStat.reachSubscribers) && Objects.equals(hide, wallpostStat.hide) && Objects.equals(toGroup, wallpostStat.toGroup) && Objects.equals(unsubscribe, wallpostStat.unsubscribe) && Objects.equals(reachTotal, wallpostStat.reachTotal) && Objects.equals(report, wallpostStat.report) && Objects.equals(links, wallpostStat.links); }
Example #14
Source File: BEParser.java From bt with Apache License 2.0 | 5 votes |
/** * Create a parser for the provided URL's content. * * @param url URL's content must be a well-formed bencoded document. * @since 1.0 */ public BEParser(URL url) { Objects.requireNonNull(url, "Missing URL"); try { this.scanner = new Scanner(url.openStream()); } catch (IOException e) { throw new BtParseException("Failed to open stream for URL: " + url, new byte[0], e); } this.type = getTypeForPrefix((char) scanner.peek()); }
Example #15
Source File: BulkSendingCopyTab.java From docusign-java-client with MIT License | 5 votes |
@Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } BulkSendingCopyTab bulkSendingCopyTab = (BulkSendingCopyTab) o; return Objects.equals(this.initialValue, bulkSendingCopyTab.initialValue) && Objects.equals(this.tabLabel, bulkSendingCopyTab.tabLabel); }
Example #16
Source File: ResultsDAO.java From pikatimer with GNU General Public License v3.0 | 5 votes |
public ReportDestination getReportDestinationByID(Integer id) { //System.out.println("Looking for a timingLocation with id " + id); // This is ugly. Setup a map for faster lookups if (!reportDestinationListInitialized.get()) refreshReportDestinationList(); Optional<ReportDestination> result = reportDestinationList.stream() .filter(t -> Objects.equals(t.getID(), id)) .findFirst(); if (result.isPresent()) { //System.out.println("Found " + result.get().LocationNameProperty()); return result.get(); } return null; }
Example #17
Source File: Loader.java From Bytecoder with Apache License 2.0 | 5 votes |
@Override public Enumeration<URL> getResources(String name) throws IOException { Objects.requireNonNull(name); // this loader List<URL> urls = findResourcesAsList(name); // parent loader Enumeration<URL> e; if (parent != null) { e = parent.getResources(name); } else { e = BootLoader.findResources(name); } // concat the URLs with the URLs returned by the parent return new Enumeration<>() { final Iterator<URL> iterator = urls.iterator(); @Override public boolean hasMoreElements() { return (iterator.hasNext() || e.hasMoreElements()); } @Override public URL nextElement() { if (iterator.hasNext()) { return iterator.next(); } else { return e.nextElement(); } } }; }
Example #18
Source File: Node.java From SPDS with Eclipse Public License 2.0 | 5 votes |
public final boolean equals(Object o) { if (o == this) return true; if (o instanceof Map.Entry) { Map.Entry<?, ?> e = (Map.Entry<?, ?>) o; if (Objects.equals(key, e.getKey()) && Objects.equals(value, e.getValue())) return true; } return false; }
Example #19
Source File: AtlasJanusElement.java From atlas with Apache License 2.0 | 5 votes |
@Override public void removePropertyValue(String propertyName, Object propertyValue) { Iterator<? extends Property<Object>> it = getWrappedElement().properties(propertyName); while (it.hasNext()) { Property currentProperty = it.next(); Object currentPropertyValue = currentProperty.value(); if (Objects.equals(currentPropertyValue, propertyValue)) { currentProperty.remove(); break; } } }
Example #20
Source File: GenericItemProvider.java From smarthome with Eclipse Public License 2.0 | 5 votes |
protected boolean hasItemChanged(Item item1, Item item2) { return !Objects.equals(item1.getClass(), item2.getClass()) || // !Objects.equals(item1.getName(), item2.getName()) || // !Objects.equals(item1.getCategory(), item2.getCategory()) || // !Objects.equals(item1.getGroupNames(), item2.getGroupNames()) || // !Objects.equals(item1.getLabel(), item2.getLabel()) || // !Objects.equals(item1.getTags(), item2.getTags()) || // !Objects.equals(item1.getType(), item2.getType()) || // hasGroupItemChanged(item1, item2); }
Example #21
Source File: AdditionalPropertiesBoolean.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o; return Objects.equals(this.name, additionalPropertiesBoolean.name) && super.equals(o); }
Example #22
Source File: LocalExecutorITCase.java From flink with Apache License 2.0 | 5 votes |
@Test(timeout = 90_000L) public void testStreamQueryExecutionTableMultipleTimes() throws Exception { final URL url = getClass().getClassLoader().getResource("test-data.csv"); Objects.requireNonNull(url); final Map<String, String> replaceVars = new HashMap<>(); replaceVars.put("$VAR_PLANNER", planner); replaceVars.put("$VAR_SOURCE_PATH1", url.getPath()); replaceVars.put("$VAR_EXECUTION_TYPE", "streaming"); replaceVars.put("$VAR_RESULT_MODE", "table"); replaceVars.put("$VAR_UPDATE_MODE", "update-mode: append"); replaceVars.put("$VAR_MAX_ROWS", "100"); final String query = "SELECT scalarUDF(IntegerField1), StringField1 FROM TableNumber1"; final List<String> expectedResults = new ArrayList<>(); expectedResults.add("47,Hello World"); expectedResults.add("27,Hello World"); expectedResults.add("37,Hello World"); expectedResults.add("37,Hello World"); expectedResults.add("47,Hello World"); expectedResults.add("57,Hello World!!!!"); final Executor executor = createModifiedExecutor(clusterClient, replaceVars); final SessionContext session = new SessionContext("test-session", new Environment()); String sessionId = executor.openSession(session); assertEquals("test-session", sessionId); try { for (int i = 0; i < 3; i++) { executeStreamQueryTable(replaceVars, query, expectedResults); } } finally { executor.closeSession(sessionId); } }
Example #23
Source File: ZoneOffsetTransitionRule.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Creates an instance defining the yearly rule to create transitions between two offsets. * * @param month the month of the month-day of the first day of the cutover week, from 1 to 12 * @param dayOfMonthIndicator the day of the month-day of the cutover week, positive if the week is that * day or later, negative if the week is that day or earlier, counting from the last day of the month, * from -28 to 31 excluding 0 * @param dayOfWeek the required day-of-week, -1 if the month-day should not be changed * @param time the cutover time in the 'before' offset, not null * @param timeEndOfDay whether the time is midnight at the end of day * @param timeDefnition how to interpret the cutover * @param standardOffset the standard offset in force at the cutover, not null * @param offsetBefore the offset before the cutover, not null * @param offsetAfter the offset after the cutover, not null * @throws IllegalArgumentException if the day of month indicator is invalid * @throws IllegalArgumentException if the end of day flag is true when the time is not midnight */ ZoneOffsetTransitionRule( int month, int dayOfMonthIndicator, int dayOfWeek, LocalTime time, boolean timeEndOfDay, TimeDefinition timeDefnition, ZoneOffset standardOffset, ZoneOffset offsetBefore, ZoneOffset offsetAfter) { Objects.requireNonNull(time, "time"); Objects.requireNonNull(timeDefnition, "timeDefnition"); Objects.requireNonNull(standardOffset, "standardOffset"); Objects.requireNonNull(offsetBefore, "offsetBefore"); Objects.requireNonNull(offsetAfter, "offsetAfter"); if (month < 1 || month > 12) { throw new IllegalArgumentException("month must be between 1 and 12"); } if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) { throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero"); } if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) { throw new IllegalArgumentException("Time must be midnight when end of day flag is true"); } this.month = month; this.dom = (byte) dayOfMonthIndicator; this.dow = dayOfWeek; this.time = time; this.timeEndOfDay = timeEndOfDay; this.timeDefinition = timeDefnition; this.standardOffset = standardOffset; this.offsetBefore = offsetBefore; this.offsetAfter = offsetAfter; }
Example #24
Source File: SchemaITest.java From pulsar-flink with Apache License 2.0 | 5 votes |
private <T> void checkRead(SchemaType type, List<T> datas, Function<T, String> toStr, Class<T> tClass) throws Exception { StreamExecutionEnvironment see = StreamExecutionEnvironment.getExecutionEnvironment(); see.setParallelism(1); StreamTableEnvironment tEnv = StreamTableEnvironment.create(see); String table = newTopic(); sendTypedMessages(table, type, datas, Optional.empty(), tClass); tEnv.connect(getPulsarSourceDescriptor(table)) .inAppendMode() .registerTableSource(table); Table t = tEnv.scan(table).select("value"); tEnv.toAppendStream(t, t.getSchema().toRowType()) .map(new FailingIdentityMapper<>(datas.size())) .addSink(new SingletonStreamSink.StringSink<>()).setParallelism(1); Thread reader = new Thread("read") { @Override public void run() { try { see.execute("read from earliest"); } catch (Throwable e) { // do nothing } } }; reader.start(); reader.join(); if (toStr == null) { SingletonStreamSink.compareWithList(datas.subList(0, datas.size() - 1).stream().map(Objects::toString).collect(Collectors.toList())); } else { SingletonStreamSink.compareWithList(datas.subList(0, datas.size() - 1).stream().map(e -> toStr.apply(e)).collect(Collectors.toList())); } }
Example #25
Source File: RowFieldName.java From presto with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RowFieldName other = (RowFieldName) o; return Objects.equals(this.name, other.name); }
Example #26
Source File: HdfsBackupRepository.java From lucene-solr with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public void init(NamedList args) { this.config = args; // Configure the size of the buffer used for copying index files to/from HDFS, if specified. if (args.get(HDFS_COPY_BUFFER_SIZE_PARAM) != null) { this.copyBufferSize = (Integer)args.get(HDFS_COPY_BUFFER_SIZE_PARAM); if (this.copyBufferSize <= 0) { throw new IllegalArgumentException("Value of " + HDFS_COPY_BUFFER_SIZE_PARAM + " must be > 0"); } } String hdfsSolrHome = (String) Objects.requireNonNull(args.get(HdfsDirectoryFactory.HDFS_HOME), "Please specify " + HdfsDirectoryFactory.HDFS_HOME + " property."); Path path = new Path(hdfsSolrHome); while (path != null) { // Compute the path of root file-system (without requiring an additional system property). baseHdfsPath = path; path = path.getParent(); } // We don't really need this factory instance. But we want to initialize it here to // make sure that all HDFS related initialization is at one place (and not duplicated here). factory = new HdfsDirectoryFactory(); factory.init(args); this.hdfsConfig = factory.getConf(new Path(hdfsSolrHome)); // Configure the umask mode if specified. if (args.get(HDFS_UMASK_MODE_PARAM) != null) { String umaskVal = (String)args.get(HDFS_UMASK_MODE_PARAM); this.hdfsConfig.set(FsPermission.UMASK_LABEL, umaskVal); } try { this.fileSystem = FileSystem.get(this.baseHdfsPath.toUri(), this.hdfsConfig); } catch (IOException e) { throw new SolrException(ErrorCode.SERVER_ERROR, e); } }
Example #27
Source File: CallbackServer.java From vk-java-sdk with MIT License | 5 votes |
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CallbackServer callbackServer = (CallbackServer) o; return Objects.equals(secretKey, callbackServer.secretKey) && Objects.equals(creatorId, callbackServer.creatorId) && Objects.equals(id, callbackServer.id) && Objects.equals(title, callbackServer.title) && Objects.equals(url, callbackServer.url) && Objects.equals(status, callbackServer.status); }
Example #28
Source File: ViewMetaData.java From crate with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ViewMetaData view = (ViewMetaData) o; return Objects.equals(stmt, view.stmt) && Objects.equals(owner, view.owner); }
Example #29
Source File: Model200Response.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Model200Response _200response = (Model200Response) o; return Objects.equals(this.name, _200response.name) && Objects.equals(this.propertyClass, _200response.propertyClass); }
Example #30
Source File: FailActionHTTPLocalResponse.java From sdk with Apache License 2.0 | 5 votes |
@Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } FailActionHTTPLocalResponse failActionHTTPLocalResponse = (FailActionHTTPLocalResponse) o; return Objects.equals(this.file, failActionHTTPLocalResponse.file) && Objects.equals(this.statusCode, failActionHTTPLocalResponse.statusCode); }