java.util.Map#hashCode ( )源码实例Demo

下面列出了java.util.Map#hashCode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: uyuni   文件: ListSessionSetHelper.java

/**
 * Initializes this instance, determining the name of the set that will be used
 * and instantiating it.
 *
 * @param prefix basis for the generation of a unique set name
 */
private void setup(String prefix) {
    RequestContext context = getContext();
    helper = new SessionSetHelper(context.getRequest());

    if (StringUtils.isBlank(prefix)) {
        prefix = getListable().getClass().getName();
    }
    decl = prefix;

    Map params = getParamMap();
    if (!params.isEmpty()) {
        decl = decl + params.hashCode();
    }

    set = SessionSetHelper.lookupAndBind(context.getRequest(),
        decl);

}
 
源代码2 项目: RetrofitGO   文件: OneReponsitory.java

public Flowable<Resource<MovieModel>> loadOneData(Map<String, String> params) {
    String mCacheKey = this.getClass().getName()
            + "." + Thread.currentThread().getStackTrace()[2].getMethodName()
            + "." + params.hashCode();
    return new CommonNetBoundResource<MovieModel>(CachePolicyMode.POLICY_NETWORK_ELSE_CACHE) {
        @NonNull
        @Override
        protected Flowable fetchFromNet() {
            return mOneWebService.getMovie(params).compose(RxHelper::handleResponse);
        }

        @Override
        protected String getCacheKey() {
            return mCacheKey;
        }
    }.getFlowable();
}
 
源代码3 项目: gcs   文件: TrueTypeEmbedder.java

/**
 * Returns an uppercase 6-character unique tag for the given subset.
 */
public String getTag(Map<Integer, Integer> gidToCid)
{
    // deterministic
    long num = gidToCid.hashCode();

    // base25 encode
    StringBuilder sb = new StringBuilder();
    do
    {
        long div = num / 25;
        int mod = (int)(num % 25);
        sb.append(BASE25.charAt(mod));
        num = div;
    } while (num != 0 && sb.length() < 6);

    // pad
    while (sb.length() < 6)
    {
        sb.insert(0, 'A');
    }

    sb.append('+');
    return sb.toString();
}
 
源代码4 项目: sambox   文件: FontUtils.java

/**
 * @return an uppercase 6-character unique tag for the given subset.
 */
public static String getTag(Map<Integer, Integer> gidToCid)
{
    // deterministic
    long num = gidToCid.hashCode();

    // base25 encode
    StringBuilder sb = new StringBuilder();
    do
    {
        long div = num / 25;
        int mod = (int) (num % 25);
        sb.append(BASE25.charAt(mod));
        num = div;
    } while (num != 0 && sb.length() < 6);

    // pad
    while (sb.length() < 6)
    {
        sb.insert(0, 'A');
    }

    return sb.append('+').toString();
}
 
源代码5 项目: PdfBox-Android   文件: TrueTypeEmbedder.java

/**
 * Returns an uppercase 6-character unique tag for the given subset.
 */
public String getTag(Map<Integer, Integer> gidToCid)
{
    // deterministic
    long num = gidToCid.hashCode();

    // base25 encode
    StringBuilder sb = new StringBuilder();
    do
    {
        long div = num / 25;
        int mod = (int)(num % 25);
        sb.append(BASE25.charAt(mod));
        num = div;
    } while (num != 0 && sb.length() < 6);

    // pad
    while (sb.length() < 6)
    {
        sb.insert(0, 'A');
    }

    sb.append('+');
    return sb.toString();
}
 
源代码6 项目: spacewalk   文件: ListSessionSetHelper.java

/**
 * Initializes this instance, determining the name of the set that will be used
 * and instantiating it.
 *
 * @param prefix basis for the generation of a unique set name
 */
private void setup(String prefix) {
    RequestContext context = getContext();
    helper = new SessionSetHelper(context.getRequest());

    if (StringUtils.isBlank(prefix)) {
        prefix = getListable().getClass().getName();
    }
    decl = prefix;

    Map params = getParamMap();
    if (!params.isEmpty()) {
        decl = decl + params.hashCode();
    }

    set = SessionSetHelper.lookupAndBind(context.getRequest(),
        decl);

}
 
源代码7 项目: AsciidocFX   文件: ChartBuilderService.java

public boolean chartBuild(String chartContent, String imagesDir, String imageTarget, Map<String, String> optMap) {

        if (!imageTarget.endsWith(".png")) {
            return false;
        }

        Integer cacheHit = current.getCache().get(imageTarget);
        int hashCode = (imageTarget + imagesDir + chartContent).hashCode() + optMap.hashCode();

        if (Objects.nonNull(cacheHit))
            if (hashCode == cacheHit) {
                return false;
            }

        current.getCache().put(imageTarget, hashCode);

        currentRoot = current.currentTab().getParentOrWorkdir();
        imagePath = currentRoot.resolve(imageTarget);

        return true;
    }
 
源代码8 项目: businessworks   文件: ProxyFactory.java

IndicesCallbackFilter(List<Method> methods) {
  final Map<Object, Integer> indices = Maps.newHashMap();
  for (int i = 0; i < methods.size(); i++) {
    indices.put(MethodWrapper.create(methods.get(i)), i);
  }
  this.indices = indices;
  this.hashCode = indices.hashCode();
}
 
源代码9 项目: gemfirexd-oss   文件: OptionSet.java

@Override
public int hashCode() {
    Map<AbstractOptionSpec<?>, List<String>> thisOptionsToArguments =
        new HashMap<AbstractOptionSpec<?>, List<String>>( optionsToArguments );
    return detectedOptions.hashCode()
        ^ thisOptionsToArguments.hashCode()
        ^ nonOptionArguments.hashCode();
}
 
源代码10 项目: lucene-solr   文件: Clause.java

Clause(Map<String, Object> original, Condition tag, Condition globalTag, boolean isStrict, Put put, boolean nodeSetPresent) {
  this.hashCode = original.hashCode();
  this.original = original;
  this.tag = tag;
  this.globalTag = globalTag;
  this.globalTag.clause = this;
  this.type = null;
  this.hasComputedValue = false;
  this.strict = isStrict;
  derivedFrom = null;
  this.put = put;
  this.nodeSetPresent = nodeSetPresent;
}
 
源代码11 项目: cuba   文件: AbstractWindow.java

protected int getScreenHashCode(Screen screen) {
    ScreenContext screenContext = UiControllerUtils.getScreenContext(screen);
    WindowInfo windowInfo = screenContext.getWindowInfo();

    Map<String, Object> params = getFrame().getContext().getParams();
    return windowInfo.hashCode() + (params != null ? params.hashCode() : 0);
}
 

/**
 * Gets the {@link ConnectionAdapter} that corresponds to the given {@link ConnectionInformation} and {@link Operator}.
 * Uses the {@link ValueProviderHandlerRegistry#injectValues(ConnectionInformation, Operator, boolean) injection mechanism}
 * to create a fully functional adapter and {@link #validate(Function, Function) validates} the adapter before
 * returning it. If the validation fails, will throw a {@link ConnectionAdapterException} with the given operator,
 * connection information's name and type, as well as the {@link ValidationResult}.
 *
 * @param connection
 * 		the connection; must not be {@code null}
 * @param operator
 * 		the operator for context; may be {@code null}
 * @return the adapter, never {@code null}
 * @throws ConnectionAdapterException
 * 		if a {@link #validate(Function, Function) validation} on the injected values fails
 * @throws ConfigurationException
 * 		if an error occurs
 * @see ValueProviderHandlerRegistry#injectValues(ConnectionInformation, Operator, boolean)
 * @see #create(String, Map)
 */
public T getAdapter(ConnectionInformation connection, Operator operator) throws ConnectionAdapterException, ConfigurationException {
	ConnectionCacheHash hash = new ConnectionCacheHash();
	try {
		Repository repo = connection.getRepository();
		if (repo != null) {
			hash.location = new RepositoryLocationBuilder().withExpectedDataEntryType(ConnectionEntry.class).buildFromPathComponents(repo.getName(),
					new String[]{Folder.CONNECTION_FOLDER_NAME, connection.getConfiguration().getName()}).getAbsoluteLocation();
		} else {
			hash.location = connection.getConfiguration().getName();
		}
	} catch (MalformedRepositoryLocationException e) {
		// ignore
	}
	ConnectionConfiguration configuration = ValidationUtil.requireNonNull(connection, "connection").getConfiguration();
	Map<String, ConfigurationParameter> keyMap = configuration.getKeyMap();

	Map<String, String> valueMap = ValueProviderHandlerRegistry.getInstance().injectValues(connection, operator, false);
	ValidationResult validation = validate(valueMap::get, keyMap::get);
	if (validation.getType() == ResultType.FAILURE) {
		throw new ConnectionAdapterException(operator, configuration, validation);
	}
	// remove all null values and get rid of group prefix
	Map<String, String> adapterMap = valueMap.entrySet().stream().filter(e ->  e.getValue() != null)
			.collect(Collectors.toMap(e -> e.getKey().substring(e.getKey().indexOf('.') + 1), Entry::getValue));
	if (operator != null && operator.getProcess() != null) {
		hash.paramHash = adapterMap.hashCode();
		T cachedAdapter = findAdapter(operator.getProcess(), getConfigurableClass(), hash);
		if (cachedAdapter != null) {
			return cachedAdapter;
		}
	}
	T adapter = create(configuration.getName(), adapterMap);
	if (operator != null && operator.getProcess() != null) {
		registerAdapter(operator.getProcess(), hash, adapter);
	}
	return adapter;
}
 
源代码13 项目: gemfirexd-oss   文件: OptionSet.java

@Override
public int hashCode() {
    Map<AbstractOptionSpec<?>, List<String>> thisOptionsToArguments =
        new HashMap<AbstractOptionSpec<?>, List<String>>( optionsToArguments );
    return detectedOptions.hashCode()
        ^ thisOptionsToArguments.hashCode()
        ^ nonOptionArguments.hashCode();
}
 

/**
 * Adds a new web resource to mock a request.
 *
 * @param parameters
 * @param result
 */
public void setWebResource(Map<String, String> parameters, String result) {
	int hash = parameters.hashCode();
	if (this.webResources.containsKey(hash)) {
		logger.warn("Overwriting mocked result for parameters "
				+ parameters.toString());
	}
	this.webResources.put(hash, result.getBytes(StandardCharsets.UTF_8));
}
 
源代码15 项目: adventure   文件: CompoundBinaryTagImpl.java

CompoundBinaryTagImpl(final Map<String, BinaryTag> tags) {
  this.tags = Collections.unmodifiableMap(tags);
  this.hashCode = tags.hashCode();
}
 
源代码16 项目: vespa   文件: StateMetricContext.java

private StateMetricContext(Map<String, String> data) {
    this.data = data;
    this.hashCode = data.hashCode();
}
 
源代码17 项目: cqengine   文件: MapEntity.java

public MapEntity(Map mapToWrap) {
    this(mapToWrap, mapToWrap.hashCode());
}
 
源代码18 项目: hawkular-agent   文件: ResourceManager.java

@Override
public int compare(Resource<L> r1, Resource<L> r2) {
    // make sure we are looking at the same resource
    int c = r1.getID().compareTo(r2.getID());
    if (c != 0) {
        return c;
    }

    // see if the names changed
    c = r1.getName().compareTo(r2.getName());
    if (c != 0) {
        return c;
    }

    // see if the resource configuration property values are the same
    Collection<ResourceConfigurationPropertyInstance<L>> rcp1 = r1.getResourceConfigurationProperties();
    Collection<ResourceConfigurationPropertyInstance<L>> rcp2 = r2.getResourceConfigurationProperties();
    if (rcp1.size() == rcp2.size()) {
        if (!rcp1.isEmpty()) {
            Map<ResourceConfigurationPropertyInstance<L>, String> rcp1Map = new HashMap<>(rcp1.size());
            for (ResourceConfigurationPropertyInstance<L> rcp1Item : rcp1) {
                rcp1Map.put(rcp1Item, rcp1Item.getValue());
            }
            Map<ResourceConfigurationPropertyInstance<L>, String> rcp2Map = new HashMap<>(rcp2.size());
            for (ResourceConfigurationPropertyInstance<L> rcp2Item : rcp2) {
                rcp2Map.put(rcp2Item, rcp2Item.getValue());
            }
            if (!rcp1Map.equals(rcp2Map)) {
                return rcp1Map.hashCode() < rcp2Map.hashCode() ? -1 : 1;
            }
        }
    } else {
        return rcp1.size() < rcp2.size() ? -1 : 1;
    }

    // see if the general properties are the same
    if (!r1.getProperties().equals(r2.getProperties())) {
        return r1.getProperties().hashCode() < r2.getProperties().hashCode() ? -1 : 1;
    }

    // everything we care about didn't change - consider them the same resource
    return 0;
}
 
源代码19 项目: spork   文件: SchemaTuple.java

protected int hashCodePiece(int hash, Map<String, Object> v, boolean isNull) {
    return isNull ? hash : 31 * hash + v.hashCode();
}
 

public ConfigFeatureFlagValuesTransition(Map<Label, String> flagValues) {
  this(ImmutableSortedMap.copyOf(flagValues), flagValues.hashCode());
}