Java Code Examples for java.util.Objects.toString()

The following are Jave code examples for showing how to use toString() of the java.util.Objects class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Cognizant-Intelligent-Test-Scripter   File: TestSetAutoSuggest.java   View Source Code Vote up 6 votes
private void initAutoSuggest() {
    scenarioAutoSuggest = new AutoSuggest() {

        @Override
        public void beforeSearch(String text) {
            setSearchList(Utils.asStringList(sProject.getScenarios()));
        }
    };
    testCaseAutoSuggest = new AutoSuggest() {
        @Override
        public void beforeSearch(String text) {
            clearSearchList();
            String scenario = Objects.toString(table.getValueAt(table.getSelectedRow(), 1), "");
            if (!scenario.trim().isEmpty()
                    && sProject.getScenarioByName(scenario) != null) {
                setSearchList(Utils.asStringList(sProject.getScenarioByName(scenario).getTestCases()));
            }
        }

    };
    iterationAutoSuggest = new AutoSuggest().withSearchList(getIterationList());
    browserAutoSuggest = new AutoSuggest();
    platformAutoSuggest = new AutoSuggest().withSearchList(getPlatformList());
}
 
Example 2
Project: crawling-framework   File: HttpSourceCSVUtils.java   View Source Code Vote up 6 votes
public static String[] mapHttpSourceToCsvRow(HttpSource ld) {
    return new String[]{
            ld.getUrl(), ld.getName(), ld.getLanguage(), ld.getTimezone(),
            String.valueOf(ld.isEnabled()), String.valueOf(ld.isDiscoveryEnabled()),
            Objects.toString(ld.getUrlRecrawlDelayInSecs(), ""),
            Objects.toString(ld.getFeedRecrawlDelayInSecs(), ""),
            Objects.toString(ld.getSitemapRecrawlDelayInSecs(), ""),
            Utils.listToText(ld.getUrls()), Utils.listToText(ld.getFeeds()), Utils.listToText(ld.getSitemaps()),
            Utils.listToText(ld.getCategories()), Utils.listToText(ld.getAppIds()),
            Utils.listToText(ld.getUrlFilters()), Utils.listToText(ld.getUrlNormalizers()),
            Utils.listToText(ld.getTitleSelectors()),
            Utils.listToText(ld.getTextSelectors()), Utils.listToText(ld.getTextNormalizers()),
            Utils.listToText(ld.getDateSelectors()), Utils.listToText(ld.getDateRegexps()),
            Utils.listToText(ld.getDateFormats())
    };
}
 
Example 3
Project: openjdk-jdk10   File: Module.java   View Source Code Vote up 6 votes
/**
 * Creates a new named Module. The resulting Module will be defined to the
 * VM but will not read any other modules, will not have any exports setup
 * and will not be registered in the service catalog.
 */
Module(ModuleLayer layer,
       ClassLoader loader,
       ModuleDescriptor descriptor,
       URI uri)
{
    this.layer = layer;
    this.name = descriptor.name();
    this.loader = loader;
    this.descriptor = descriptor;

    // define module to VM

    boolean isOpen = descriptor.isOpen() || descriptor.isAutomatic();
    Version version = descriptor.version().orElse(null);
    String vs = Objects.toString(version, null);
    String loc = Objects.toString(uri, null);
    String[] packages = descriptor.packages().toArray(new String[0]);
    defineModule0(this, isOpen, vs, loc, packages);
}
 
Example 4
Project: fake-smtp-server   File: EmailFactory.java   View Source Code Vote up 6 votes
public Email convert(RawData rawData) throws IOException {
    try {
        Session s = Session.getDefaultInstance(new Properties());
        MimeMessage mimeMessage = new MimeMessage(s, rawData.getContentAsStream());
        String subject = Objects.toString(mimeMessage.getSubject(), UNDEFINED);
        ContentType contentType = ContentType.fromString(mimeMessage.getContentType());
        Object messageContent = mimeMessage.getContent();

        switch (contentType) {
            case HTML:
            case PLAIN:
                return buildPlainOrHtmlEmail(rawData, subject, contentType, messageContent);
            case MULTIPART_ALTERNATIVE:
                return buildMultipartAlternativeMail(rawData, subject, (Multipart) messageContent);
            default:
                throw new IllegalStateException("Unsupported e-mail content type " + contentType.name());
        }
    } catch (MessagingException e) {
        return buildFallbackEmail(rawData);
    }
}
 
Example 5
Project: master-basic   File: StrBuffer.java   View Source Code Vote up 5 votes
public StrBuffer appendWithSeparators(final Iterator<?> it, final String separator) {
	if (it != null) {
		final String sep = Objects.toString(separator, "");
		while (it.hasNext()) {
			append(it.next());
			if (it.hasNext()) {
				append(sep);
			}
		}
	}
	return this;
}
 
Example 6
Project: openjdk-jdk10   File: Asserts.java   View Source Code Vote up 5 votes
/**
 * Asserts that {@code value} is {@code false}.
 *
 * @param value The value assumed to be false.
 * @param msg A description of the assumption; {@code null} for a default message.
 * @throws RuntimeException if the assertion is not true.
 */
public static void assertFalse(boolean value, String msg) {
    if (value) {
        msg = Objects.toString(msg, "assertFalse")
                + ": expected false, was true";
        fail(msg);
    }
}
 
Example 7
Project: crawling-framework   File: HttpSourceTestCSVUtils.java   View Source Code Vote up 5 votes
public static String[] mapHttpSourceTestToCsvRow(HttpSourceTest httpSourceTest) {
    return new String[]{
            httpSourceTest.getUrl(), httpSourceTest.getSource(),
            BaseEncoding.base64().encode(httpSourceTest.getHtml().getBytes(Charsets.UTF_8)),
            Objects.toString(httpSourceTest.getUrlAccepted(), "false"),
            Strings.nullToEmpty(httpSourceTest.getTitle()),
            Strings.nullToEmpty(httpSourceTest.getText()),
            Strings.nullToEmpty(httpSourceTest.getDate())
    };
}
 
Example 8
Project: luna   File: TraversableHashMap.java   View Source Code Vote up 5 votes
@Override
public T next() {
  K k = key;
  Entry<K, V> e = entries.get(k);
  if (e == null) {
    throw new NoSuchElementException(Objects.toString(key));
  }

  nextCalled = true;
  key = e.getNextKey();
  return get(k, e);
}
 
Example 9
Project: openjdk-jdk10   File: Asserts.java   View Source Code Vote up 5 votes
/**
 * Asserts that {@code lhs} is equal to {@code rhs}.
 *
 * @param lhs The left hand side of the comparison.
 * @param rhs The right hand side of the comparison.
 * @param msg A description of the assumption; {@code null} for a default message.
 * @throws RuntimeException if the assertion is not true.
 */
public static void assertEquals(Object lhs, Object rhs, String msg) {
    if ((lhs != rhs) && ((lhs == null) || !(lhs.equals(rhs)))) {
        msg = Objects.toString(msg, "assertEquals")
                + ": expected " + Objects.toString(lhs)
                + " to equal " + Objects.toString(rhs);
        fail(msg);
    }
}
 
Example 10
Project: jdk8u-jdk   File: FilterUSRTest.java   View Source Code Vote up 4 votes
public String toString() {
    return super.toString() + "//" + Objects.toString(obj);
}
 
Example 11
Project: Cognizant-Intelligent-Test-Scripter   File: TestStep.java   View Source Code Vote up 4 votes
public String getReference() {
    return Objects.toString(stepDetails.get(HEADERS.Reference.getIndex()), "");
}
 
Example 12
Project: Cognizant-Intelligent-Test-Scripter   File: TestStep.java   View Source Code Vote up 4 votes
public String getTag() {
    return Objects.toString(stepDetails.get(HEADERS.Step.getIndex()), "");
}
 
Example 13
Project: powsybl-core   File: AppStorageDataSource.java   View Source Code Vote up 4 votes
@Override
public String toString() {
    return START_PATTERN + Objects.toString(suffix, "") + SEPARATOR + Objects.toString(ext, "");
}
 
Example 14
Project: openNaEF   File: KeseranPOJOUtil.java   View Source Code Vote up 4 votes
/**
 * Port の POJO を作る
 */
public static PasaranPOJO toPOJO(AbstractPort port) {
    PasaranPOJO pojo = createPOJO(port);

    pojo.name = Objects.toString(AbstractPort.Attr.IFNAME.get(port), "");
    pojo.objectType = getObjectType(port);

    if (port instanceof VlanIf) {
        pojo.vlanId = VlanIf.Attr.VLAN_ID.get((VlanIf) port);
        VlanIf vlanIfMvo = (VlanIf) port;
        pojo.taggedPorts = vlanIfMvo.getCurrentTaggedPorts().stream()
                .map(p -> MvoUtil.toMvoId((MVO)p))
                .collect(Collectors.toList());
        pojo.untaggedPorts = vlanIfMvo.getCurrentUntaggedPorts().stream()
                .map(p -> MvoUtil.toMvoId((MVO)p))
                .collect(Collectors.toList());

        MvoSet<Port> aliases = AbstractPort.Attr.ALIASES.get(port);
        if (aliases != null) {
            pojo.aliases = new ArrayList<>();
            pojo.aliases.addAll(
                    aliases.get().stream()
                            .map(alias -> MvoUtil.toMvoId((MVO) alias))
                            .collect(Collectors.toList()));
            pojo.owner = MvoUtil.toMvoId((MVO) port.getOwner());
        }
    }

    if (port instanceof EthLagIf) {
        pojo.memberPorts = new ArrayList<>();
        pojo.memberPorts.addAll(
                port.getParts().stream()
                        .map(p -> MvoUtil.toMvoId((AbstractPort) p))
                        .collect(Collectors.toList()));
    }

    if (port instanceof IpIf) {
        MvoSet<Port> associatedPorts = IpIf.ASSOCIATED_PORTS.get((IpIf) port);
        if (associatedPorts != null) {
            pojo.associatedPorts =
                    associatedPorts.get().stream()
                            .map(associatedPort -> MvoUtil.toMvoId((MVO) associatedPort))
                            .collect(Collectors.toList());
        }

        MvoMap<Port, Integer> boundPorts = IpIf.Attr.BOUND_PORTS.get((IpIf) port);
        if (boundPorts != null) {
            pojo.boundPorts = boundPorts.getKeys().stream()
                    .collect(Collectors.toMap(
                            key -> MvoUtil.toMvoId((MVO) key),
                            boundPorts::get
                    ));
        }
    }

    return pojo;
}
 
Example 15
Project: datarouter   File: ObjectTool.java   View Source Code Vote up 4 votes
public static String nullSafeToString(Object object){
	return Objects.toString(object, null);
}
 
Example 16
Project: openNaEF   File: ToDateTime.java   View Source Code Vote up 4 votes
@Override
public String toString(Date value) {
    if (value == null) return null;
    return Objects.toString(value.getTime(), null);
}
 
Example 17
Project: circus-train   File: ReplicaTableFactory.java   View Source Code Vote up 4 votes
private String toStringOrEmpty(Object value) {
  return Objects.toString(value, "");
}
 
Example 18
Project: Cognizant-Intelligent-Test-Scripter   File: TestStep.java   View Source Code Vote up 4 votes
public String getCondition() {
    return Objects.toString(stepDetails.get(HEADERS.Condition.getIndex()), "");
}
 
Example 19
Project: jdk8u-jdk   File: Component.java   View Source Code Vote up 3 votes
/**
 * Returns a string representing the state of this component. This
 * method is intended to be used only for debugging purposes, and the
 * content and format of the returned string may vary between
 * implementations. The returned string may be empty but may not be
 * <code>null</code>.
 *
 * @return  a string representation of this component's state
 * @since     JDK1.0
 */
protected String paramString() {
    final String thisName = Objects.toString(getName(), "");
    final String invalid = isValid() ? "" : ",invalid";
    final String hidden = visible ? "" : ",hidden";
    final String disabled = enabled ? "" : ",disabled";
    return thisName + ',' + x + ',' + y + ',' + width + 'x' + height
            + invalid + hidden + disabled;
}
 
Example 20
Project: openjdk-jdk10   File: InetAddress.java   View Source Code Vote up 2 votes
/**
 * Converts this IP address to a {@code String}. The
 * string returned is of the form: hostname / literal IP
 * address.
 *
 * If the host name is unresolved, no reverse name service lookup
 * is performed. The hostname part will be represented by an empty string.
 *
 * @return  a string representation of this IP address.
 */
public String toString() {
    String hostName = holder().getHostName();
    return Objects.toString(hostName, "")
        + "/" + getHostAddress();
}