code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static <C> PortableClassAccess<C> get(Class<C> clazz) {
@SuppressWarnings("unchecked")
PortableClassAccess<C> access = (PortableClassAccess<C>) CLASS_ACCESSES.get(clazz);
if (access != null) {
return access;
}
access = new PortableClassAccess<C>(clazz);
... | java |
@SuppressWarnings("deprecation") // No good alternative in the Hibernate API yet
protected ID extractId(T entity) {
final Class<?> entityClass = TypeHelper.getTypeArguments(JpaBaseRepository.class, this.getClass()).get(0);
final SessionFactory sf = (SessionFactory)(getEntityManager().getEntityManagerFactory()... | java |
public final <T> T allocateInstance(Class<T> clazz) throws IllegalStateException {
try {
@SuppressWarnings("unchecked")
final T result = (T) THE_UNSAFE.allocateInstance(clazz);
return result;
} catch (InstantiationException e) {
throw new IllegalStateException("Cannot allocate instance: " + e.getMessag... | java |
public final <T> T shallowCopy(T obj) {
long size = shallowSizeOf(obj);
long address = THE_UNSAFE.allocateMemory(size);
long start = toAddress(obj);
THE_UNSAFE.copyMemory(start, address, size);
@SuppressWarnings("unchecked")
final T result = (T) fromAddress(address);
return result;
} | java |
public final Object fromAddress(long address) {
Object[] array = new Object[] { null };
long baseOffset = THE_UNSAFE.arrayBaseOffset(Object[].class);
THE_UNSAFE.putLong(array, baseOffset, address);
return array[0];
} | java |
public final void copyPrimitiveField(Object source, Object copy, Field field) {
copyPrimitiveAtOffset(source, copy, field.getType(), getObjectFieldOffset(field));
} | java |
public final void copyPrimitiveAtOffset(Object source, Object copy, Class<?> type, long offset) {
if (java.lang.Boolean.TYPE == type) {
boolean origFieldValue = THE_UNSAFE.getBoolean(source, offset);
THE_UNSAFE.putBoolean(copy, offset, origFieldValue);
} else if (java.lang.Byte.TYPE == type) {
byte origFi... | java |
public final void deepCopyObjectAtOffset(Object source, Object copy, Class<?> fieldClass, long offset) {
deepCopyObjectAtOffset(source, copy, fieldClass, offset, new IdentityHashMap<Object, Object>(100));
} | java |
public final void deepCopyArrayField(Object obj, Object copy, Field field, IdentityHashMap<Object, Object> referencesToReuse) {
deepCopyArrayAtOffset(obj, copy, field.getType(), getObjectFieldOffset(field), referencesToReuse);
} | java |
public final void putObject(Object parent, long offset, Object value) {
THE_UNSAFE.putObject(parent, offset, value);
} | java |
public static Class<?> getClass(ClassLoader classLoader, String className) {
try {
final Class<?> clazz;
if (PRIMITIVE_MAPPING.containsKey(className)) {
String qualifiedName = "[" + PRIMITIVE_MAPPING.get(className);
clazz = Class.forName(qualifi... | java |
public static String determineQualifiedName(String className) {
String readableClassName = StringUtils.removeWhitespace(className);
if (readableClassName == null) {
throw new IllegalArgumentException("readableClassName must not be null.");
} else if (readableClassName.endsW... | java |
public static String determineReadableClassName(String qualifiedName) {
String readableClassName = StringUtils.removeWhitespace(qualifiedName);
if (readableClassName == null) {
throw new IllegalArgumentException("qualifiedName must not be null.");
} else if (readableClassName... | java |
protected List<Class<? extends Annotation>> determineQualifiers(Annotation bindingAnnotation, Annotation... allAnnotations) {
List<Class<? extends Annotation>> result = new ArrayList<Class<? extends Annotation>>();
// The binding annotation itself is marked with @BindingScope
Class<? exte... | java |
static void validateValueUniquenessInScope(String qualifiedName,
List<TypeElement> nestedElements) {
Set<String> names = new LinkedHashSet<>();
for (TypeElement nestedElement : nestedElements) {
if (nestedElement instanceof EnumElement) {
EnumElement enumElement = (EnumElement) nestedElement... | java |
static boolean isValidTag(int value) {
return (value >= MIN_TAG_VALUE && value < RESERVED_TAG_VALUE_START)
|| (value > RESERVED_TAG_VALUE_END && value <= MAX_TAG_VALUE);
} | java |
public static OptionElement findByName(List<OptionElement> options, String name) {
checkNotNull(options, "options");
checkNotNull(name, "name");
OptionElement found = null;
for (OptionElement option : options) {
if (option.name().equals(name)) {
if (found != null) {
throw new Il... | java |
private OptionKindAndValue readKindAndValue() {
char peeked = peekChar();
switch (peeked) {
case '{':
return OptionKindAndValue.of(OptionElement.Kind.MAP, readMap('{', '}', ':'));
case '[':
return OptionKindAndValue.of(OptionElement.Kind.LIST, readList());
case '"':
ret... | java |
private void addToList(List<Object> list, Object value) {
if (value instanceof List) {
list.addAll((List) value);
} else {
list.add(value);
}
} | java |
private DataType readDataType() {
String name = readWord();
switch (name) {
case "map":
if (readChar() != '<') throw unexpected("expected '<'");
DataType keyType = readDataType();
if (readChar() != ',') throw unexpected("expected ','");
DataType valueType = readDataType();
... | java |
private int readInt() {
String tag = readWord();
try {
int radix = 10;
if (tag.startsWith("0x") || tag.startsWith("0X")) {
tag = tag.substring("0x".length());
radix = 16;
}
return Integer.valueOf(tag, radix);
} catch (Exception e) {
throw unexpected("expected an... | java |
@Override
public JmxMetricReporter init(ConfigurationProperties configurationProperties, MetricRegistry metricRegistry) {
if (configurationProperties.isJmxEnabled()) {
jmxReporter = JmxReporter
.forRegistry(metricRegistry)
.inDomain(MetricRegistry.name(get... | java |
@Override
public Slf4jMetricReporter init(ConfigurationProperties configurationProperties, MetricRegistry metricRegistry) {
metricLogReporterMillis = configurationProperties.getMetricLogReporterMillis();
if (metricLogReporterMillis > 0) {
this.slf4jReporter = Slf4jReporter
... | java |
public void close() {
long endNanos = System.nanoTime();
long durationNanos = endNanos - startNanos;
connectionPoolCallback.releaseConnection(durationNanos);
} | java |
public static <T> T lookup(String name) {
InitialContext initialContext = initialContext();
try {
@SuppressWarnings("unchecked")
T object = (T) initialContext.lookup(name);
if (object == null) {
throw new NameNotFoundException(name + " was found but is... | java |
public ConnectionDecoratorFactory resolve() {
int loadingIndex = Integer.MIN_VALUE;
ConnectionDecoratorFactory connectionDecoratorFactory = null;
Iterator<ConnectionDecoratorFactoryService> connectionDecoratorFactoryServiceIterator = serviceLoader.iterator();
while (connectionDecoratorFa... | java |
public Connection newInstance(Connection target, ConnectionPoolCallback connectionPoolCallback) {
return proxyConnection(target, new ConnectionCallback(connectionPoolCallback));
} | java |
public static ClassLoader getClassLoader() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
return (classLoader != null) ? classLoader : ClassLoaderUtils.class.getClassLoader();
} | java |
@SuppressWarnings("unchecked")
public static <T> Class<T> loadClass(String className) throws ClassNotFoundException {
return (Class<T>) getClassLoader().loadClass(className);
} | java |
@SuppressWarnings("unchecked")
public static boolean findClass(String className) {
try {
return getClassLoader().loadClass(className) != null;
} catch (ClassNotFoundException e) {
return false;
} catch (NoClassDefFoundError e) {
return false;
}
... | java |
public MetricsFactory resolve() {
for (MetricsFactoryService metricsFactoryService : serviceLoader) {
MetricsFactory metricsFactory = metricsFactoryService.load();
if (metricsFactory != null) {
return metricsFactory;
}
}
throw new IllegalStateE... | java |
private <T extends DataSource> T applyDataSourceProperties(T dataSource) {
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
String key = entry.getKey().toString();
String value = entry.getValue().toString();
String propertyKey = PropertyKey.DATA_SOURCE_PROPERT... | java |
private <T> T instantiateClass(PropertyKey propertyKey) {
T object = null;
String property = properties.getProperty(propertyKey.getKey());
if (property != null) {
try {
Class<T> clazz = ClassLoaderUtils.loadClass(property);
LOGGER.debug("Instantiate {}... | java |
private Integer integerProperty(PropertyKey propertyKey) {
Integer value = null;
String property = properties.getProperty(propertyKey.getKey());
if (property != null) {
value = Integer.valueOf(property);
}
return value;
} | java |
private Long longProperty(PropertyKey propertyKey) {
Long value = null;
String property = properties.getProperty(propertyKey.getKey());
if (property != null) {
value = Long.valueOf(property);
}
return value;
} | java |
private Boolean booleanProperty(PropertyKey propertyKey) {
Boolean value = null;
String property = properties.getProperty(propertyKey.getKey());
if (property != null) {
value = Boolean.valueOf(property);
}
return value;
} | java |
@SuppressWarnings("unchecked")
private <T> T jndiLookup(PropertyKey propertyKey) {
String property = properties.getProperty(propertyKey.getKey());
if (property != null) {
return isJndiLazyLookup() ?
(T) LazyJndiResolver.newInstance(property, DataSource.class) :
... | java |
private Connection getConnection(ConnectionRequestContext context) throws SQLException {
concurrentConnectionRequestCountHistogram.update(concurrentConnectionRequestCount.incrementAndGet());
long startNanos = System.nanoTime();
try {
Connection connection = null;
if ... | java |
protected boolean incrementPoolSize(int expectingMaxSize) {
Integer maxSize = null;
long currentOverflowPoolSize;
try {
lock.lockInterruptibly();
int currentMaxSize = poolAdapter.getMaxPoolSize();
boolean incrementMaxPoolSize = currentMaxSize < maxOver... | java |
public static <T> T getFieldValue(Object target, String fieldName) {
try {
Field field = target.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
@SuppressWarnings("unchecked")
T returnValue = (T) field.get(target);
return returnValue;... | java |
public static void setFieldValue(Object target, String fieldName, Object value) {
try {
Field field = target.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
field.set(target, value);
} catch (NoSuchFieldException e) {
throw handleExcepti... | java |
public static Method getMethod(Object target, String methodName, Class... parameterTypes) {
try {
return target.getClass().getMethod(methodName, parameterTypes);
} catch (NoSuchMethodException e) {
throw handleException(methodName, e);
}
} | java |
public static boolean hasMethod(Class<?> targetClass, String methodName, Class... parameterTypes) {
try {
targetClass.getMethod(methodName, parameterTypes);
return true;
} catch (NoSuchMethodException e) {
return false;
}
} | java |
public static Method getSetter(Object target, String property, Class<?> parameterType) {
String setterMethodName = SETTER_PREFIX + property.substring(0, 1).toUpperCase() + property.substring(1);
return getMethod(target, setterMethodName, parameterType);
} | java |
public static <T> T invoke(Object target, Method method, Object... parameters) {
try {
@SuppressWarnings("unchecked")
T returnValue = (T) method.invoke(target, parameters);
return returnValue;
} catch (InvocationTargetException e) {
throw handleException(m... | java |
public static void invokeSetter(Object target, String property, Object parameter) {
Method setter = getSetter(target, property, parameter.getClass());
try {
setter.invoke(target, parameter);
} catch (IllegalAccessException e) {
throw handleException(setter.getName(), e);
... | java |
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (target == null) {
target = JndiUtils.lookup(name);
}
return method.invoke(target, args);
} | java |
@SuppressWarnings("unchecked")
public static <T> T newInstance(String name, Class<?> objectType) {
return (T) Proxy.newProxyInstance(
ClassLoaderUtils.getClassLoader(),
new Class[]{objectType},
new LazyJndiResolver(name));
} | java |
public static URI create(Path pathToVault, String... pathComponentsInsideVault) {
try {
return new URI(URI_SCHEME, pathToVault.toUri().toString(), "/" + String.join("/", pathComponentsInsideVault), null, null);
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Can not create URI from gi... | java |
public static boolean containsVault(Path pathToVault, String masterkeyFilename) {
Path masterKeyPath = pathToVault.resolve(masterkeyFilename);
Path dataDirPath = pathToVault.resolve(Constants.DATA_DIR_NAME);
return Files.isReadable(masterKeyPath) && Files.isDirectory(dataDirPath);
} | java |
public TwoPhaseMove prepareMove(Path src, Path dst) throws FileAlreadyExistsException {
return new TwoPhaseMove(src, dst);
} | java |
public synchronized FileChannel newFileChannel(EffectiveOpenOptions options) throws IOException {
Path path = currentFilePath.get();
if (options.truncateExisting()) {
chunkCache.invalidateAll();
}
FileChannel ciphertextFileChannel = null;
CleartextFileChannel cleartextFileChannel = null;
try {... | java |
public Path resolveConflictsIfNecessary(Path ciphertextPath, String dirId) throws IOException {
String ciphertextFileName = ciphertextPath.getFileName().toString();
String basename = StringUtils.removeEnd(ciphertextFileName, LONG_NAME_FILE_EXT);
Matcher m = CIPHERTEXT_FILENAME_PATTERN.matcher(basename);
if (!m.... | java |
private Path resolveConflict(Path conflictingPath, String ciphertextFileName, String dirId) throws IOException {
String conflictingFileName = conflictingPath.getFileName().toString();
Preconditions.checkArgument(conflictingFileName.contains(ciphertextFileName), "%s does not contain %s", conflictingPath, ciphertextF... | java |
private Path renameConflictingFile(Path canonicalPath, Path conflictingPath, String ciphertext, String dirId, String dirPrefix) throws IOException {
try {
String cleartext = cryptor.fileNameCryptor().decryptFilename(ciphertext, dirId.getBytes(StandardCharsets.UTF_8));
Path alternativePath = canonicalPath;
fo... | java |
private boolean resolveDirectoryConflictTrivially(Path canonicalPath, Path conflictingPath) throws IOException {
if (!Files.exists(canonicalPath)) {
Files.move(conflictingPath, canonicalPath, StandardCopyOption.ATOMIC_MOVE);
return true;
} else if (hasSameDirFileContent(conflictingPath, canonicalPath)) {
/... | java |
public boolean needsMigration(Path pathToVault, String masterkeyFilename) throws IOException {
Path masterKeyPath = pathToVault.resolve(masterkeyFilename);
byte[] keyFileContents = Files.readAllBytes(masterKeyPath);
KeyFile keyFile = KeyFile.parse(keyFileContents);
return keyFile.getVersion() < Constants.VAULT_... | java |
public void migrate(Path pathToVault, String masterkeyFilename, CharSequence passphrase) throws NoApplicableMigratorException, InvalidPassphraseException, IOException {
Path masterKeyPath = pathToVault.resolve(masterkeyFilename);
byte[] keyFileContents = Files.readAllBytes(masterKeyPath);
KeyFile keyFile = KeyFil... | java |
public com.google.api.ads.adwords.axis.v201809.cm.Image getCollapsedImage() {
return collapsedImage;
} | java |
public com.google.api.ads.adwords.axis.v201809.cm.Image getExpandedImage() {
return expandedImage;
} | java |
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
} | java |
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
... | java |
public void setPremiumFeature(com.google.api.ads.admanager.axis.v201902.PremiumFeature premiumFeature) {
this.premiumFeature = premiumFeature;
} | java |
public com.google.api.ads.admanager.axis.v201902.RateType getRateType() {
return rateType;
} | java |
public void setRateType(com.google.api.ads.admanager.axis.v201902.RateType rateType) {
this.rateType = rateType;
} | java |
public void setAdjustmentType(com.google.api.ads.admanager.axis.v201902.PremiumAdjustmentType adjustmentType) {
this.adjustmentType = adjustmentType;
} | java |
public com.google.api.ads.adwords.axis.v201809.cm.Criterion getCriterion() {
return criterion;
} | java |
public com.google.api.ads.adwords.axis.v201809.cm.BidModifierSource getBidModifierSource() {
return bidModifierSource;
} | java |
public com.google.api.ads.adwords.axis.v201809.cm.UrlList getSitelinkFinalUrls() {
return sitelinkFinalUrls;
} | java |
public com.google.api.ads.adwords.axis.v201809.cm.UrlList getSitelinkFinalMobileUrls() {
return sitelinkFinalMobileUrls;
} | java |
public com.google.api.ads.adwords.axis.v201809.cm.CustomParameters getSitelinkUrlCustomParameters() {
return sitelinkUrlCustomParameters;
} | java |
public com.google.api.ads.admanager.axis.v201902.Date getStartDate() {
return startDate;
} | java |
public void setEndDate(com.google.api.ads.admanager.axis.v201902.Date endDate) {
this.endDate = endDate;
} | java |
private static Long createBudget(AdWordsServicesInterface adWordsServices, AdWordsSession session)
throws RemoteException, ApiException {
// Get the BudgetService.
BudgetServiceInterface budgetService =
adWordsServices.get(session, BudgetServiceInterface.class);
// Create the campaign budget.... | java |
private static void setCampaignTargetingCriteria(
Campaign campaign, AdWordsServicesInterface adWordsServices, AdWordsSession session)
throws ApiException, RemoteException {
// Get the CampaignCriterionService.
CampaignCriterionServiceInterface campaignCriterionService =
adWordsServices.get(... | java |
public V callWithRetries() throws ApiInvocationException {
V result = null;
Throwable lastError = null;
for (int kthAttempt = 1; retryStrategy.canDoThisAttempt(kthAttempt); ++kthAttempt) {
// Wait if the previous attempt failed.
long waitForMillis =
retryStrategy.calcWaitTimeBefor... | java |
public com.google.api.ads.adwords.axis.v201809.o.AttributeType getKey() {
return key;
} | java |
public com.google.api.ads.adwords.axis.v201809.cm.AdvertisingChannelType getAdvertisingChannelType() {
return advertisingChannelType;
} | java |
public com.google.api.ads.admanager.axis.v201808.DeviceCapabilityTargeting getDeviceCapabilityTargeting() {
return deviceCapabilityTargeting;
} | java |
public com.google.api.ads.admanager.axis.v201808.MobileDeviceTargeting getMobileDeviceTargeting() {
return mobileDeviceTargeting;
} | java |
public com.google.api.ads.admanager.axis.v201805.DaiAuthenticationKeyType getKeyType() {
return keyType;
} | java |
public void setKeyType(com.google.api.ads.admanager.axis.v201805.DaiAuthenticationKeyType keyType) {
this.keyType = keyType;
} | java |
public com.google.api.ads.admanager.axis.v201805.DateTime getStartDateTime() {
return startDateTime;
} | java |
public void setRoadblockingType(com.google.api.ads.admanager.axis.v201805.RoadblockingType roadblockingType) {
this.roadblockingType = roadblockingType;
} | java |
public com.google.api.ads.admanager.axis.v201805.CreativeRotationType getCreativeRotationType() {
return creativeRotationType;
} | java |
public void setFrequencyCaps(com.google.api.ads.admanager.axis.v201805.FrequencyCap[] frequencyCaps) {
this.frequencyCaps = frequencyCaps;
} | java |
public com.google.api.ads.admanager.axis.v201805.Targeting getTargeting() {
return targeting;
} | java |
public void setTargeting(com.google.api.ads.admanager.axis.v201805.Targeting targeting) {
this.targeting = targeting;
} | java |
public com.google.api.ads.admanager.axis.v201805.BaseCustomFieldValue[] getCustomFieldValues() {
return customFieldValues;
} | java |
public com.google.api.ads.admanager.axis.v201805.ProposalLineItemConstraints getProductConstraints() {
return productConstraints;
} | java |
public void setProductConstraints(com.google.api.ads.admanager.axis.v201805.ProposalLineItemConstraints productConstraints) {
this.productConstraints = productConstraints;
} | java |
public void setPremiums(com.google.api.ads.admanager.axis.v201805.ProposalLineItemPremium[] premiums) {
this.premiums = premiums;
} | java |
public com.google.api.ads.admanager.axis.v201805.Money getBaseRate() {
return baseRate;
} | java |
public com.google.api.ads.admanager.axis.v201805.Money getGrossCost() {
return grossCost;
} | java |
public void setGrossCost(com.google.api.ads.admanager.axis.v201805.Money grossCost) {
this.grossCost = grossCost;
} | java |
public com.google.api.ads.admanager.axis.v201805.BillingCap getBillingCap() {
return billingCap;
} | java |
public com.google.api.ads.admanager.axis.v201805.DateTime getLastModifiedDateTime() {
return lastModifiedDateTime;
} | java |
public com.google.api.ads.admanager.axis.v201805.EnvironmentType getEnvironmentType() {
return environmentType;
} | java |
public com.google.api.ads.admanager.axis.v201805.LinkStatus getLinkStatus() {
return linkStatus;
} | java |
public com.google.api.ads.admanager.axis.v201805.ProgrammaticCreativeSource getProgrammaticCreativeSource() {
return programmaticCreativeSource;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.