类java.util.Objects源码实例Demo

下面列出了怎么用java.util.Objects的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjdk-jdk8u   文件: IntPipeline.java
@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));
                }
            };
        }
    };
}
 
源代码2 项目: openjdk-8   文件: AnnotationSupport.java
/**
 * 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;
}
 
源代码3 项目: sumk   文件: RpcLocker.java
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);
}
 
源代码4 项目: director-sdk   文件: DiagnosticDataSummary.java
@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);
}
 
源代码5 项目: teku   文件: Deposit.java
@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());
}
 
源代码6 项目: ReactionDecoder   文件: RBlastSmilesGenerator.java
/**
 * 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();
}
 
/**
 * 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;
        }
    }
}
 
源代码8 项目: FHIR   文件: ResearchSubjectStatus.java
@Override
public int hashCode() {
    int result = hashCode;
    if (result == 0) {
        result = Objects.hash(id, extension, value);
        hashCode = result;
    }
    return result;
}
 
源代码9 项目: Digital   文件: FormatToExpression.java
@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());
}
 
源代码10 项目: netstrap   文件: NettyHttpResponse.java
/**
 * 写数据
 */
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);
}
 
源代码11 项目: java-ilp-core   文件: CodecContext.java
/**
 * 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;
}
 
@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);
}
 
源代码13 项目: vk-java-sdk   文件: WallpostStat.java
@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);
}
 
源代码14 项目: bt   文件: BEParser.java
/**
 * 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());
}
 
源代码15 项目: docusign-java-client   文件: BulkSendingCopyTab.java
@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);
}
 
源代码16 项目: pikatimer   文件: ResultsDAO.java
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;
}
 
源代码17 项目: Bytecoder   文件: Loader.java
@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();
            }
        }
    };
}
 
源代码18 项目: SPDS   文件: Node.java
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;
}
 
源代码19 项目: atlas   文件: AtlasJanusElement.java
@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;
        }
    }
}
 
源代码20 项目: smarthome   文件: GenericItemProvider.java
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);
}
 
@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);
}
 
源代码22 项目: flink   文件: LocalExecutorITCase.java
@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);
	}
}
 
源代码23 项目: dragonwell8_jdk   文件: ZoneOffsetTransitionRule.java
/**
 * 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;
}
 
源代码24 项目: pulsar-flink   文件: SchemaITest.java
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()));
    }
}
 
源代码25 项目: presto   文件: RowFieldName.java
@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);
}
 
源代码26 项目: lucene-solr   文件: HdfsBackupRepository.java
@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);
  }
}
 
源代码27 项目: vk-java-sdk   文件: CallbackServer.java
@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);
}
 
源代码28 项目: crate   文件: ViewMetaData.java
@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);
}
 
源代码29 项目: openapi-generator   文件: Model200Response.java
@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);
}
 
源代码30 项目: sdk   文件: FailActionHTTPLocalResponse.java
@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);
}
 
 类所在包
 同包方法