Example usage for com.google.common.primitives UnsignedLongs toString

List of usage examples for com.google.common.primitives UnsignedLongs toString

Introduction

In this page you can find the example usage for com.google.common.primitives UnsignedLongs toString.

Prototype

@CheckReturnValue
public static String toString(long x, int radix) 

Source Link

Document

Returns a string representation of x for the given radix, where x is treated as unsigned.

Usage

From source file:net.minecrell.serverlistplus.core.util.UUIDs.java

private static String toHexString(long unsigned) {
    return Strings.padStart(UnsignedLongs.toString(unsigned, 16), 16, '0');
}

From source file:com.google.jenkins.plugins.dsl.YamlProjectFactory.java

/** {@inheritDoc} */
@Override//from   ww w .j  av a2s  .  co m
public YamlProject<T> newInstance(final Branch branch) {
    try {
        // If the branch name contains '/' then use its MD5 hash
        // as the project name, but otherwise use the branch name
        // for backwards compatibility.
        final String hashedName = UnsignedLongs
                .toString(Hashing.md5().hashString(branch.getName(), Charsets.UTF_8).asLong(), 16);
        final String projectName = branch.getName().indexOf('/') == -1 ? branch.getName() : hashedName;
        final YamlProject<T> project = new YamlProject<T>((YamlMultiBranchProject<T>) getOwner(), projectName,
                null /* module */);

        // Set the display name so that it is always the branch name.
        project.setDisplayName(branch.getName());

        project.setBranch(branch);

        return decorate(project);
    } catch (IOException e) {
        logger.log(SEVERE, e.getMessage(), e);
        return null;
    }
}

From source file:org.onlab.util.Tools.java

/**
 * Converts a long value to hex string; 16 wide and sans 0x.
 *
 * @param value long value/*from   www .  j ava2 s.c om*/
 * @return hex string
 */
public static String toHex(long value) {
    return Strings.padStart(UnsignedLongs.toString(value, 16), 16, '0');
}

From source file:org.onlab.util.Tools.java

/**
 * Converts a long value to hex string; 16 wide and sans 0x.
 *
 * @param value long value//from   www  .  j  av a 2 s .  c  o  m
 * @param width string width; zero padded
 * @return hex string
 */
public static String toHex(long value, int width) {
    return Strings.padStart(UnsignedLongs.toString(value, 16), width, '0');
}