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

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

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

Boolean.valueOf介绍

[英]Parses the specified string as a boolean value.
[中]将指定字符串解析为布尔值。

代码示例

代码示例来源:origin: apache/incubator-dubbo

public static Boolean boxed(boolean v) {
  return Boolean.valueOf(v);
}

代码示例来源:origin: apache/incubator-dubbo

public static Boolean boxed(boolean v) {
  return Boolean.valueOf(v);
}

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

public Object getObject () {
    return Boolean.valueOf(value);
  }
};

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

public Object getObject () {
    return Boolean.valueOf(value);
  }
};

代码示例来源:origin: square/retrofit

@Override public Boolean convert(ResponseBody value) throws IOException {
  return Boolean.valueOf(value.string());
 }
}

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

public boolean isDecrypt(Properties connectionProperties, Properties configFileProperties) {
  String decrypterId = connectionProperties.getProperty(CONFIG_DECRYPT);
  if (decrypterId == null || decrypterId.length() == 0) {
    if (configFileProperties != null) {
      decrypterId = configFileProperties.getProperty(CONFIG_DECRYPT);
    }
  }
  if (decrypterId == null || decrypterId.length() == 0) {
    decrypterId = System.getProperty(SYS_PROP_CONFIG_DECRYPT);
  }
  return Boolean.valueOf(decrypterId);
}

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

/**
 * Append a boolean field value.
 * @param fieldName the name of the field, usually the member variable name
 * @param value the field value
 * @return this, to support call-chaining
 */
public ToStringCreator append(String fieldName, boolean value) {
  return append(fieldName, Boolean.valueOf(value));
}

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

@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
  super.doParse(element, parserContext, builder);
  builder.addPropertyValue("ignoreInvalidKeys",
      Boolean.valueOf(element.getAttribute("ignore-unresolvable")));
}

代码示例来源:origin: shuzheng/zheng

@Override
public void setProperties(Properties properties) {
  super.setProperties(properties);
  this.addGWTInterface = Boolean.valueOf(properties.getProperty("addGWTInterface")).booleanValue();
  this.suppressJavaInterface = Boolean.valueOf(properties.getProperty("suppressJavaInterface")).booleanValue();
}

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

@Override
public int hashCode() {
  final int prime = 31;
  int result = 1;
  result = prime * result + (Boolean.valueOf(parenthesized).hashCode());
  result = prime * result + distionOption;
  result = prime * result + ((from == null) ? 0 : from.hashCode());
  result = prime * result + ((groupBy == null) ? 0 : groupBy.hashCode());
  result = prime * result + ((into == null) ? 0 : into.hashCode());
  result = prime * result + ((selectList == null) ? 0 : selectList.hashCode());
  result = prime * result + ((where == null) ? 0 : where.hashCode());
  return result;
}

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

public static boolean getBooleanConfigParameter(String name, boolean defaultValue) {
  String value = getStringConfigParameter(name,null);
  return (value==null)?defaultValue:Boolean.valueOf(value);
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Gets this mutable as an instance of Boolean.
 *
 * @return a Boolean instance containing the value from this mutable, never null
 * @since 2.5
 */
public Boolean toBoolean() {
  return Boolean.valueOf(booleanValue());
}

代码示例来源:origin: apache/incubator-dubbo

private boolean isForceUseTag(Invocation invocation) {
  return Boolean.valueOf(invocation.getAttachment(FORCE_USE_TAG, url.getParameter(FORCE_USE_TAG, "false")));
}

代码示例来源:origin: apache/incubator-dubbo

private boolean isForceUseTag(Invocation invocation) {
  return Boolean.valueOf(invocation.getAttachment(FORCE_USE_TAG, url.getParameter(FORCE_USE_TAG, "false")));
}

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

protected boolean resolveProxyTargetClass(BeanDefinition beanDefinition) {
  boolean proxyTargetClass = this.defaultProxyTargetClass;
  Object attributeValue = beanDefinition.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
  if (attributeValue instanceof Boolean) {
    proxyTargetClass = (Boolean) attributeValue;
  }
  else if (attributeValue instanceof String) {
    proxyTargetClass = Boolean.valueOf((String) attributeValue);
  }
  else if (attributeValue != null) {
    throw new BeanDefinitionStoreException("Invalid proxy target class attribute [" +
        PROXY_TARGET_CLASS_ATTRIBUTE + "] with value '" + attributeValue +
        "': needs to be of type Boolean or String");
  }
  return proxyTargetClass;
}

代码示例来源:origin: ctripcorp/apollo

@Override
public void initialize(ConfigurableApplicationContext context) {
 ConfigurableEnvironment environment = context.getEnvironment();
 String enabled = environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED, "false");
 if (!Boolean.valueOf(enabled)) {
  logger.debug("Apollo bootstrap config is not enabled for context {}, see property: ${{}}", context, PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED);
  return;
 }
 logger.debug("Apollo bootstrap config is enabled for context {}", context);
 initialize(environment);
}

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

@SuppressWarnings("unchecked")
@Override
public <T> T getOption(ChannelOption<T> option) {
  if (option == SO_RCVBUF) {
    return (T) Integer.valueOf(getReceiveBufferSize());
  }
  if (option == SO_REUSEADDR) {
    return (T) Boolean.valueOf(isReuseAddress());
  }
  if (option == SO_BACKLOG) {
    return (T) Integer.valueOf(getBacklog());
  }
  return super.getOption(option);
}

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

@Bean
public Bar bar() {
  return new Bar(Boolean.valueOf(env.getProperty("bar.enabled")));
}

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

@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
  boolean proxyTargetClass = true;
  if (node instanceof Element) {
    Element ele = (Element) node;
    if (ele.hasAttribute(PROXY_TARGET_CLASS)) {
      proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS));
    }
  }
  // Register the original bean definition as it will be referenced by the scoped proxy
  // and is relevant for tooling (validation, navigation).
  BeanDefinitionHolder holder =
      ScopedProxyUtils.createScopedProxy(definition, parserContext.getRegistry(), proxyTargetClass);
  String targetBeanName = ScopedProxyUtils.getTargetBeanName(definition.getBeanName());
  parserContext.getReaderContext().fireComponentRegistered(
      new BeanComponentDefinition(definition.getBeanDefinition(), targetBeanName));
  return holder;
}

代码示例来源:origin: google/guava

public void testCompare() {
 for (boolean x : VALUES) {
  for (boolean y : VALUES) {
   // note: spec requires only that the sign is the same
   assertEquals(x + ", " + y, Boolean.valueOf(x).compareTo(y), Booleans.compare(x, y));
  }
 }
}

相关文章