Guava Interner - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava Interner class.

This code example shows how to use the following methods:intern
    /** Keep track of tags that have been seen before and reuse. */ 
    private static final Interner<Tag> TAG_CACHE = Interners.newWeakInterner();
 
    /** Intern strings used for tag keys or values. */ 
    public static String intern(String v) {
        return STR_CACHE.intern(v);
    } 
 
    /** Returns the canonical representation of a tag. */ 
    public static Tag intern(Tag t) {
        return TAG_CACHE.intern(t);
    } 
 
    /** 
     * Interns custom tag types, assumes that basic tags are already interned. This is used to 
     * ensure that we have a common view of tags internally. In particular, different subclasses of 
     * Tag may not be equal even if they have the same key and value. Tag lists should use this to 
     * ensure the equality will work as expected. 
     */ 
    static Tag internCustom(Tag t) {
5
CodeRank
This code example shows how to use the following methods:intern
   */ 
  public static String strongIntern(String sample) {
    if (sample == null) {
      return null; 
    } 
    return strongInterner.intern(sample);
  } 
   
  /** 
   * Interns and returns a reference to the representative instance  
   * for any of a collection of string instances that are equal to each other. 
   * Retains weak reference to the instance,  
   * and so does not prevent it from being garbage-collected. 
   *  
   * @param sample string instance to be interned 
   * @return weak reference to interned string instance 
   */ 
  public static String weakIntern(String sample) {
    if (sample == null) {
      return null; 
5
CodeRank
This code example shows how to use the following methods:intern
  public void setInputFileFormatClass( 
      final Class<? extends InputFormat> inputFileFormatClass) {
    if (inputFileFormatClass == null) {
      this.inputFileFormatClass = null;
    } else { 
      this.inputFileFormatClass = (Class<? extends InputFormat>) CLASS_INTERNER.intern(inputFileFormatClass);
    } 
  } 
 
  public Class<? extends OutputFormat> getOutputFileFormatClass() {
    if (outputFileFormatClass == null && tableDesc != null) {
      setOutputFileFormatClass(tableDesc.getOutputFileFormatClass());
    } 
    return outputFileFormatClass;
  } 
 
  public void setOutputFileFormatClass(final Class<?> outputFileFormatClass) {
    Class<? extends OutputFormat> outputClass = outputFileFormatClass == null ? null :
      HiveFileFormatUtils.getOutputFormatSubstitute(outputFileFormatClass);
    if (outputClass != null) {
5
CodeRank
This code example shows how to use the following methods:intern
        return make(name, revision, false);
    } 
 
    public static CvsFile make(final String name, final String revision,
                    final boolean isDead) {
        return INTERNER.intern(new CvsFile(name, revision, isDead));
    } 
 
    private CvsFile(final String name, final String revision,
                    final boolean isDead) {
        // Could intern name in a separate INTERNER, though most files will probably not have been modified recently anyway. 
        this.name = name;
        this.revision = revision.intern();
        dead = isDead;
    } 
 
    private Object readResolve() { 
        // Could make(name, revision, dead) to reintern revision, but probably pointless since com.thoughtworks.xstream.converters.basic.StringConverter caches instances. 
        return INTERNER.intern(this);
    } 
3
CodeRank
This code example shows how to use the following methods:intern
  public static WorkflowLock lock( final AccountFullName accountFullName, final String domainUuid, final String runId ) {
    return lock( accountFullName.getAccountNumber( ), domainUuid, runId );
  } 
 
  public static WorkflowLock lock( final String accountNumber, final String domainUuid, final String runId ) {
    return workflowLockInterner.intern( new WorkflowLock( accountNumber, domainUuid, runId ) ).lock( );
  } 
 
  WorkflowLock( final String accountNumber, final String domainUuid, final String runId ) {
    this.accountNumber = accountNumber;
    this.domainUuid = domainUuid;
    this.runId = runId;
  } 
 
  public WorkflowLock lock( ) { 
    lock.lock( );
    return this;
  } 
 
  @Override 
4
CodeRank
See Code Examples for Guava Interner Methods: