当前位置: 首页>>代码示例>>Java>>正文


Java Generators类代码示例

本文整理汇总了Java中com.fasterxml.uuid.Generators的典型用法代码示例。如果您正苦于以下问题:Java Generators类的具体用法?Java Generators怎么用?Java Generators使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Generators类属于com.fasterxml.uuid包,在下文中一共展示了Generators类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensureGeneratorInitialized

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
private static void ensureGeneratorInitialized() {
    if (timeGenerator == null) {
        synchronized (UUIDUtils.class) {
            if (timeGenerator == null) {
                timeGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
            }
        }
    }
    if (randomGenerator == null) {
        synchronized (com.fasterxml.uuid.UUIDGenerator.class) {
            if (randomGenerator == null) {
                randomGenerator = Generators.randomBasedGenerator();
            }
        }
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:17,代码来源:UUIDUtils.java

示例2: shortUuid

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
/**
 * Generate short version random UUID
 *
 * @return UUID
 */
public static String shortUuid() {
    RandomBasedGenerator generator = Generators.randomBasedGenerator();
    UUID uuid = generator.generate();
    // https://gist.github.com/LeeSanghoon/5811136
    long l = ByteBuffer.wrap(uuid.toString().getBytes()).getLong();
    return Long.toString(l, Character.MAX_RADIX);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:13,代码来源:UUIDs.java

示例3: toJSONObject

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
public JSONObject toJSONObject() throws JSONException {
    JSONObject object = new JSONObject();
    object.put("type", type);
    object.put("name", name);
    object.put("failures", failuresToJSON());
    object.put("status", status);
    if ( index == null ) {
        globalID++;
        index = Generators.timeBasedGenerator().generate();
    }
    object.put("tindex", index);
    object.put("series", getSeries());

    if(parent != null)
        object.put("parent",parent.toJSONObject());

    object.put("transplantationPoint", CtElemToJSON(transplantationPoint));
    return object;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:20,代码来源:RemoveParameterCondition.java

示例4: toJSONObject

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
public JSONObject toJSONObject() throws JSONException {
    JSONObject object = new JSONObject();
    object.put("type", type);
    object.put("name", name);
    object.put("failures", failuresToJSON());
    object.put("status", status);
    if ( index == null ) {
        globalID++;
        index = Generators.timeBasedGenerator().generate();
    }
    object.put("tindex", index);
    object.put("series", getSeries());

    if(parent != null)
        object.put("parent",parent.toJSONObject());

    return object;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:19,代码来源:Transformation.java

示例5: preStart

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
/**
 * Establishes a connection with the webtrends stream api
 * @see akka.actor.UntypedActor#preStart()
 */
public void preStart() throws Exception {
			
	// initialize the uuid generator which is based on time and ethernet address
	this.uuidGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
	
	// authenticate with the webtrends service
	WebtrendsTokenRequest tokenRequest = new WebtrendsTokenRequest(this.authUrl, this.authAudience, this.authScope, this.clientId, this.clientSecret);
	this.oAuthToken = tokenRequest.execute();		
	
	// initialize the webtrends stream socket client and connect the listener
	this.webtrendsStreamSocketClient = new WebSocketClient();
	try {
		this.webtrendsStreamSocketClient.start();
		ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest();
		this.webtrendsStreamSocketClient.connect(this, new URI(this.eventStreamUrl), upgradeRequest);
		await(5, TimeUnit.SECONDS);
	} catch(Exception e) {
		throw new RuntimeException("Unable to connect to web socket: " + e.getMessage(), e);
	}
	
	this.componentRegistryRef.tell(new ComponentRegistrationMessage(EVENT_SOURCE_ID, ComponentType.STREAM_LISTENER, getSelf()), getSelf());
}
 
开发者ID:mnxfst,项目名称:stream-analyzer,代码行数:27,代码来源:WebtrendsStreamListenerActor.java

示例6: getUuid

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
/**
 *
 * @return a time-based UUID, reorganized so that the time-based bits are at the front, , i.e., a bunch of UUIDs
 * coming from the same server are more or less sequential in the first four bytes, for better insertion speeds.
 *
 * @see <a href="https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/">
 *     https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/
 *     </a>
 *
 */
public static UUID getUuid()
{
    String baseUuidString = Generators.timeBasedGenerator().generate().toString();
    String[] parts = baseUuidString.split("-");
    String sortedUuidString = new StringBuilder(36).
            append(parts[2]).
            append(parts[1]).
            append("-").
            append(parts[0].substring(0, 4)).
            append("-").
            append(parts[0].substring(4, 8)).
            append("-").
            append(parts[3]).
            append("-").
            append(parts[4]).
            toString();
    return UUID.fromString(sortedUuidString);
}
 
开发者ID:SMARTRACTECHNOLOGY-PUBLIC,项目名称:smartcosmos-sdk-java,代码行数:29,代码来源:UuidUtil.java

示例7: shortUuid

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
/**
 * Generate short version UUID from given uri
 *
 * @param uri Uri/Url
 * @return UUID
 */
public static String shortUuid(URI uri) {
    NameBasedGenerator generator = Generators.nameBasedGenerator(NameBasedGenerator.NAMESPACE_URL);
    UUID uuid = generator.generate(uri.toString());
    // https://gist.github.com/LeeSanghoon/5811136
    long l = ByteBuffer.wrap(uuid.toString().getBytes()).getLong();
    return Long.toString(l, Character.MAX_RADIX);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:14,代码来源:UUIDs.java

示例8: ensureGeneratorInitialized

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
protected void ensureGeneratorInitialized() {
    if (timeBasedGenerator == null) {
        synchronized (UuidIdGenerator.class) {
            if (timeBasedGenerator == null) {
                timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
            }
        }
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:10,代码来源:UuidIdGenerator.java

示例9: ensureGeneratorInitialized

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
protected void ensureGeneratorInitialized() {
    if (timeBasedGenerator == null) {
        synchronized (StrongUuidGenerator.class) {
            if (timeBasedGenerator == null) {
                timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
            }
        }
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:10,代码来源:StrongUuidGenerator.java

示例10: ensureGeneratorInitialized

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
protected void ensureGeneratorInitialized() {
  if (timeBasedGenerator == null) {
    synchronized (StrongUuidGenerator.class) {
      if (timeBasedGenerator == null) {
        timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
      }
    }
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:10,代码来源:StrongUuidGenerator.java

示例11: CoordinationEntryEvent

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
/**
 * Constructor.
 * @param cacheId - cacheId
 * @param entityName - entityName
 * @param key - key
 * @param eventType - eventType
 * @param uuidUtils - uuidUtils
 */
public CoordinationEntryEvent(UUID cacheId, final String entityName,
                              final K key, final EventType eventType,
                              final UuidUtils uuidUtils) {
    this.cacheId = cacheId;
    this.entityName = entityName;
    this.eventType = eventType;
    this.key = key;
    uniqueIdType1 = Generators.timeBasedGenerator().generate(); // TimeUUID
    uniqueIdTime = new Date(uuidUtils.toUnixTimestamp(uniqueIdType1));
}
 
开发者ID:Excelian,项目名称:Mache,代码行数:19,代码来源:CoordinationEntryEvent.java

示例12: testTimestamps

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
@Test
public void testTimestamps() throws Exception {
    final UUID uuid = Generators.timeBasedGenerator().generate();

    final long unixTimestamp = uuidUtils.toUnixTimestamp(uuid);
    final long nowTime = System.currentTimeMillis();

    LOG.info("UnixMsFromUUID=" + unixTimestamp + ", nowMs=" + nowTime + ", delta=" + (nowTime - unixTimestamp));

    final long deltaNowEvent1 = Math.abs(nowTime - unixTimestamp);
    assertTrue(deltaNowEvent1 <= 5);
}
 
开发者ID:Excelian,项目名称:Mache,代码行数:13,代码来源:UuidUtilsTest.java

示例13: getUuid

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
@Test
public void getUuid() {
    UUID uuid = Generators.randomBasedGenerator().generate();
    System.out.println(uuid.toString());
    uuid = Generators.timeBasedGenerator().generate();
    System.out.println(uuid.toString());
}
 
开发者ID:krisjin,项目名称:bscl,代码行数:8,代码来源:JUGUUIdGeneratorTest.java

示例14: getValidUUI

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
/**
 * Takes a string and returns a valid UUI from the string if such string is a valid
 * UUI. Otherwise, generates a new UUI
 *
 * @param uuid
 * @return
 */
private UUID getValidUUI(String uuid) {
    if (uuid == null) return Generators.timeBasedGenerator().generate();
    try {
        UUID fromStringUUID = UUID.fromString(uuid);
        String toStringUUID = fromStringUUID.toString();
        if (toStringUUID.equals(uuid)) return fromStringUUID;
    } catch (IllegalArgumentException e) {
        return Generators.timeBasedGenerator().generate();
    }
    return Generators.timeBasedGenerator().generate();
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:19,代码来源:JsonTransformationInput.java

示例15: getUuidGenerator

import com.fasterxml.uuid.Generators; //导入依赖的package包/类
@Override
   public TimeBasedGenerator getUuidGenerator() {
	if (uuidGenerator == null) {
		EthernetAddress nic = EthernetAddress.fromInterface();
		if (nic == null) {
			// construct address with a random number
			nic = EthernetAddress.constructMulticastAddress();
		}
		uuidGenerator = Generators.timeBasedGenerator(nic);
	}
	return uuidGenerator;
}
 
开发者ID:Tesora,项目名称:tesora-dve-pub,代码行数:13,代码来源:Host.java


注:本文中的com.fasterxml.uuid.Generators类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。