SourceImpl.Key key = new SourceImpl.Key(useContent, useMimeType, language, useUrl, useUri, useName, usePath, internal, interactive, cached, legacy); return SOURCES.intern(key);
@Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof Key)) { return false; } Key other = (Key) obj; /* * Compare characters last as it is likely the most expensive comparison in the worst * case. */ return Objects.equals(language, other.language) && // Objects.equals(mimeType, other.mimeType) && // Objects.equals(name, other.name) && // Objects.equals(path, other.path) && // Objects.equals(uri, other.uri) && // Objects.equals(url, other.url) && // interactive == other.interactive && // internal == other.internal && cached == other.cached && compareContent(other); }
private static final Source EMPTY = new SourceImpl.Key(null, null, null, null, null, null, null, false, false, false, true).toSourceNotInterned();
return key.toSourceNotInterned(); if (source == null) { while (true) { source = key.toSourceInterned(); sourceRef = new WeakSourceRef(source, deadReferences); WeakSourceRef oldSourceRef = table.putIfAbsent(key, sourceRef);
private SourceImpl(Key key) { this.key = key; /* * SourceImpl instances are interned so a single instance can identify it. We cannot use * SourceImpl directly as the sourceId needs to be shared when a source is cloned. */ this.sourceId = new SourceId(key.hashCode()); }
private boolean compareContent(Key other) { Object otherContent = other.content; if (content == other.content) { return true; } else if (content instanceof CharSequence && otherContent instanceof CharSequence) { return compareCharacters((CharSequence) content, (CharSequence) otherContent); } else if (content instanceof ByteSequence && otherContent instanceof ByteSequence) { return compareBytes((ByteSequence) content, (ByteSequence) otherContent); } else { return false; } }