java.lang.Boolean.equals()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(199)

本文整理了Java中java.lang.Boolean.equals()方法的一些代码示例,展示了Boolean.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Boolean.equals()方法的具体详情如下:
包路径:java.lang.Boolean
类名称:Boolean
方法名:equals

Boolean.equals介绍

[英]Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must be an instance of Boolean and have the same boolean value as this object.
[中]将此实例与指定的对象进行比较,并指示它们是否相等。若要相等,o必须是布尔的实例,并且具有与此对象相同的布尔值。

代码示例

代码示例来源:origin: alibaba/druid

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  SQLDataTypeImpl dataType = (SQLDataTypeImpl) o;
  if (name != null ? !name.equals(dataType.name) : dataType.name != null) return false;
  if (arguments != null ? !arguments.equals(dataType.arguments) : dataType.arguments != null) return false;
  return withTimeZone != null ? withTimeZone.equals(dataType.withTimeZone) : dataType.withTimeZone == null;
}

代码示例来源:origin: jenkinsci/jenkins

@Override
  public boolean process(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
    if (Boolean.TRUE.equals(request.getAttribute(BasicHeaderApiTokenAuthenticator.class.getName()))) {
      chain.doFilter(request, response);
      return true;
    }
    return false;
  }
}

代码示例来源:origin: spring-projects/spring-framework

private static boolean hasMetaAnnotationTypes(
    AnnotatedElement element, @Nullable Class<? extends Annotation> annotationType, @Nullable String annotationName) {
  return Boolean.TRUE.equals(
    searchWithGetSemantics(element, annotationType, annotationName, new SimpleAnnotationProcessor<Boolean>() {
      @Override
      @Nullable
      public Boolean process(@Nullable AnnotatedElement annotatedElement, Annotation annotation, int metaDepth) {
        return (metaDepth > 0 ? Boolean.TRUE : CONTINUE);
      }
    }));
}

代码示例来源:origin: spring-projects/spring-framework

protected ScriptEngine getEngine() {
  if (Boolean.FALSE.equals(this.sharedEngine)) {
    Assert.state(this.engineName != null, "No engine name specified");
    return createEngineFromName(this.engineName);
  }
  else {
    Assert.state(this.engine != null, "No shared engine available");
    return this.engine;
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public String getAsText() {
  if (Boolean.TRUE.equals(getValue())) {
    return (this.trueString != null ? this.trueString : VALUE_TRUE);
  }
  else if (Boolean.FALSE.equals(getValue())) {
    return (this.falseString != null ? this.falseString : VALUE_FALSE);
  }
  else {
    return "";
  }
}

代码示例来源:origin: spring-projects/spring-framework

public boolean condition(String conditionExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) {
  return (Boolean.TRUE.equals(getExpression(this.conditionCache, methodKey, conditionExpression).getValue(
      evalContext, Boolean.class)));
}

代码示例来源:origin: spring-projects/spring-framework

public boolean unless(String unlessExpression, AnnotatedElementKey methodKey, EvaluationContext evalContext) {
  return (Boolean.TRUE.equals(getExpression(this.unlessCache, methodKey, unlessExpression).getValue(
      evalContext, Boolean.class)));
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Clear property skipping for this element.
 * @since 3.2.13
 */
protected void clearPropertySkipping(@Nullable PropertyValues pvs) {
  if (pvs == null) {
    return;
  }
  synchronized (pvs) {
    if (Boolean.FALSE.equals(this.skip) && this.pd != null && pvs instanceof MutablePropertyValues) {
      ((MutablePropertyValues) pvs).clearProcessedProperty(this.pd.getName());
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

private boolean alreadyPopulatedRequestContextHolder(TestContext testContext) {
  return Boolean.TRUE.equals(testContext.getAttribute(POPULATED_REQUEST_CONTEXT_HOLDER_ATTRIBUTE));
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Determine if an annotation of the specified {@code annotationName} is
 * <em>present</em> on the supplied {@link AnnotatedElement} or within the
 * annotation hierarchy <em>above</em> the specified element.
 * <p>If this method returns {@code true}, then {@link #getMergedAnnotationAttributes}
 * will return a non-null value.
 * <p>This method follows <em>get semantics</em> as described in the
 * {@linkplain AnnotatedElementUtils class-level javadoc}.
 * @param element the annotated element
 * @param annotationName the fully qualified class name of the annotation type to find
 * @return {@code true} if a matching annotation is present
 */
public static boolean isAnnotated(AnnotatedElement element, String annotationName) {
  return Boolean.TRUE.equals(searchWithGetSemantics(element, null, annotationName, alwaysTrueAnnotationProcessor));
}

代码示例来源:origin: prestodb/presto

@Override
public final void serializeWithType(Object value, JsonGenerator g, SerializerProvider provider,
    TypeSerializer typeSer) throws IOException
{
  // 27-Mar-2017, tatu: Actually here we CAN NOT serialize as number without type,
  //    since with natural types that would map to number, not boolean. So choice
  //    comes to between either add type id, or serialize as boolean. Choose
  //    latter at this point
  g.writeBoolean(Boolean.TRUE.equals(value));
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * If the {@link #REINJECT_DEPENDENCIES_ATTRIBUTE} in the supplied
 * {@link TestContext test context} has a value of {@link Boolean#TRUE},
 * this method will have the same effect as
 * {@link #prepareTestInstance(TestContext) prepareTestInstance()};
 * otherwise, this method will have no effect.
 */
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
  if (Boolean.TRUE.equals(testContext.getAttribute(REINJECT_DEPENDENCIES_ATTRIBUTE))) {
    if (logger.isDebugEnabled()) {
      logger.debug("Reinjecting dependencies for test context [" + testContext + "].");
    }
    injectDependencies(testContext);
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Determine whether the given bean should be proxied with its target
 * class rather than its interfaces. Checks the
 * {@link #PRESERVE_TARGET_CLASS_ATTRIBUTE "preserveTargetClass" attribute}
 * of the corresponding bean definition.
 * @param beanFactory the containing ConfigurableListableBeanFactory
 * @param beanName the name of the bean
 * @return whether the given bean should be proxied with its target class
 */
public static boolean shouldProxyTargetClass(
    ConfigurableListableBeanFactory beanFactory, @Nullable String beanName) {
  if (beanName != null && beanFactory.containsBeanDefinition(beanName)) {
    BeanDefinition bd = beanFactory.getBeanDefinition(beanName);
    return Boolean.TRUE.equals(bd.getAttribute(PRESERVE_TARGET_CLASS_ATTRIBUTE));
  }
  return false;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Whether to show the upgrade wizard
 */
public boolean isShowUpgradeWizard() {
  HttpSession session = Stapler.getCurrentRequest().getSession(false);
  if(session != null) {
    return Boolean.TRUE.equals(session.getAttribute(SHOW_UPGRADE_WIZARD_FLAG));
  }
  return false;
}
/**

代码示例来源:origin: spring-projects/spring-framework

/**
 * Create a JMS Connection via this template's ConnectionFactory.
 * @return the new JMS Connection
 * @throws javax.jms.JMSException if thrown by JMS API methods
 */
protected Connection doCreateConnection() throws JMSException {
  ConnectionFactory cf = getTargetConnectionFactory();
  if (Boolean.FALSE.equals(this.pubSubMode) && cf instanceof QueueConnectionFactory) {
    return ((QueueConnectionFactory) cf).createQueueConnection();
  }
  else if (Boolean.TRUE.equals(this.pubSubMode) && cf instanceof TopicConnectionFactory) {
    return ((TopicConnectionFactory) cf).createTopicConnection();
  }
  else {
    return obtainTargetConnectionFactory().createConnection();
  }
}

代码示例来源:origin: spring-projects/spring-framework

private boolean isActivated(TestContext testContext) {
  return (Boolean.TRUE.equals(testContext.getAttribute(ACTIVATE_LISTENER)) ||
      AnnotatedElementUtils.hasAnnotation(testContext.getTestClass(), WebAppConfiguration.class));
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Specify if the condition defined by the specified expression matches.
 */
public boolean condition(String conditionExpression, ApplicationEvent event, Method targetMethod,
    AnnotatedElementKey methodKey, Object[] args, @Nullable BeanFactory beanFactory) {
  EventExpressionRootObject root = new EventExpressionRootObject(event, args);
  MethodBasedEvaluationContext evaluationContext = new MethodBasedEvaluationContext(
      root, targetMethod, args, getParameterNameDiscoverer());
  if (beanFactory != null) {
    evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory));
  }
  return (Boolean.TRUE.equals(getExpression(this.conditionCache, methodKey, conditionExpression).getValue(
      evaluationContext, Boolean.class)));
}

代码示例来源:origin: skylot/jadx

public boolean compile() throws Exception {
  String fullName = clsNode.getFullName();
  String code = clsNode.getCode().toString();
  JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
  fileManager = new ClassFileManager(compiler.getStandardFileManager(null, null, null));
  List<JavaFileObject> jFiles = new ArrayList<>(1);
  jFiles.add(new CharSequenceJavaFileObject(fullName, code));
  CompilationTask compilerTask = compiler.getTask(null, fileManager, null, null, null, jFiles);
  return Boolean.TRUE.equals(compilerTask.call());
}

代码示例来源:origin: netty/netty

private void closeOnRead(ChannelPipeline pipeline) {
  if (isOpen()) {
    if (Boolean.TRUE.equals(config().getOption(ChannelOption.ALLOW_HALF_CLOSURE))) {
      shutdownInput();
      pipeline.fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
    } else {
      unsafe().close(unsafe().voidPromise());
    }
    pipeline.fireUserEventTriggered(ChannelInputShutdownReadComplete.INSTANCE);
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void setBooleanProperty() {
  BooleanTestBean target = new BooleanTestBean();
  AbstractPropertyAccessor accessor = createAccessor(target);
  accessor.setPropertyValue("bool2", "true");
  assertTrue("Correct bool2 value", Boolean.TRUE.equals(accessor.getPropertyValue("bool2")));
  assertTrue("Correct bool2 value", target.getBool2());
  accessor.setPropertyValue("bool2", "false");
  assertTrue("Correct bool2 value", Boolean.FALSE.equals(accessor.getPropertyValue("bool2")));
  assertTrue("Correct bool2 value", !target.getBool2());
}

相关文章