code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
protected void addContainerTags() {
// Only add root if we aren't it
final RootContainer rc = getRootContainer(container);
if (rc != null) {
tags.add(rc);
}
final TreeDepth parentDepth = getTreeDepth(container);
tags.add(parentDepth != null ? parentDepth.increment() : TreeDepth.ROOT);
} | java |
protected void removeContainerTags() {
tags.removeOfType(TreeMember.class);
tags.removeOfType(RootContainer.class);
tags.removeOfType(TreeDepth.class);
} | java |
protected void setContainer(final EntityContainer container) {
if (!Objects.equals(this.container, container)) {
this.container = container;
if (!isAlive()) {
return;
}
// Fix container based tags
if (container == null) {
removeContainerTags();
} else {
addContainerTags();
}
}... | java |
public void uncacheProxyOfEntity(final Entity e, final Class<? extends Entity> type) {
cache.invalidateType(e, type);
} | java |
private Map<String, TrackedNode<T>> trackNode(String path,
Map<String, TrackedNode<T>> tree,
Collection<NodeEvent<T>> events,
int depth)
throws InterruptedException, Keeper... | java |
public static <T> NamedAttributeType<T> newNamedTypeOf(final String name, final Class<T> type) {
return new NamedAttributeType<>(name, newTypeOf(type));
} | java |
public static NamedAttributeType<Object> newNamedUnknownType(final String name, final Type type) {
return new NamedAttributeType<>(name, new AttributeType<Object>(type) {});
} | java |
public static <T> AttributeType<T> newTypeOf(final Class<T> type) {
return new AttributeType<T>(type) {};
} | java |
public static String requireNotEmpty(final String str) throws NullPointerException, IllegalArgumentException {
if (str.length() == 0) {
throw new IllegalArgumentException();
}
return str;
} | java |
public boolean addWaitingWork(final T context) {
write.lock();
try {
boolean result = !waitingWork.contains(context);
if (result) {
waitingWork.add(context);
workChanged.signalAll(); // Wake up!
}
return result;
} finally {
write.unlock();
}
} | java |
public boolean isWaitingWork(final T context) {
read.lock();
try {
return waitingWork.contains(context);
} finally {
read.unlock();
}
} | java |
public boolean removeWaitingWork(final T context) {
write.lock();
try {
boolean result = waitingWork.remove(context);
if (result) {
workChanged.signalAll();
}
return result;
} finally {
write.unlock();
}
} | java |
public boolean unresolveType(final Class<? extends Entity> type) {
return resolved.remove(Objects.requireNonNull(type)) != null;
} | java |
@Override
public Stat exists(String path) throws InterruptedException, KeeperException
{
return exists(path, false);
} | java |
@Override
public ZKData<String> getZKStringData(String path) throws InterruptedException, KeeperException
{
return getZKStringData(path, null);
} | java |
@Override
public Stat createOrSetWithParents(String path, String data, List<ACL> acl, CreateMode createMode)
throws InterruptedException, KeeperException
{
if(exists(path) != null)
return setData(path, data);
try
{
createWithParents(path, data, acl, createMode);
return null;
... | java |
@Override
public void deleteWithChildren(String path) throws InterruptedException, KeeperException
{
List<String> allChildren = findAllChildren(path);
for(String child : allChildren)
{
delete(PathUtils.addPaths(path, child));
}
delete(path);
} | java |
@Override
public void waitForShutdown(Object timeout)
throws InterruptedException, IllegalStateException, TimeoutException
{
if(!_shutdown)
throw new IllegalStateException("call shutdown first");
ConcurrentUtils.joinFor(clock, _mainThread, timeout);
} | java |
protected boolean addWork(final ForkJoinContext<?> context) {
requireNotStopped(this);
final boolean result = workQueue.addWaitingWork(context);
if (result) {
addWorkerIfNeeded();
}
return result;
} | java |
public JFreeChartRender setDomainAxis(double lowerBound, double upperBound) {
ValueAxis valueAxis = getPlot().getDomainAxis();
valueAxis.setUpperBound(upperBound);
valueAxis.setLowerBound(lowerBound);
return this;
} | java |
public JFreeChartRender setRangeAxis(double lowerBound, double upperBound) {
ValueAxis valueAxis = getPlot().getRangeAxis();
valueAxis.setUpperBound(upperBound);
valueAxis.setLowerBound(lowerBound);
return this;
} | java |
public JFreeChartRender setStyle(int style) {
switch (style) {
case JFreeChartRender.STYLE_THESIS:
return this.setBaseShapesVisible(true).
setBaseShapesFilled(false).
setBaseLinesVisible(false).
setLegendItemFont... | java |
@NotNull
protected CompletableFuture<R> enqueue(@NotNull final Meta meta, @NotNull final T context) {
State<T, R> state = objectQueue.get(meta.getOid());
if (state != null) {
if (state.future.isCancelled()) {
objectQueue.remove(meta.getOid(), state);
state = null;
}
}
if (s... | java |
@NotNull
public BatchRes postBatch(@NotNull final BatchReq batchReq) throws IOException {
return doWork(auth -> doRequest(auth, new JsonPost<>(batchReq, BatchRes.class), AuthHelper.join(auth.getHref(), PATH_BATCH)), batchReq.getOperation());
} | java |
@NotNull
public <T> T getObject(@NotNull final String hash, @NotNull final StreamHandler<T> handler) throws IOException {
return doWork(auth -> {
final ObjectRes links = doRequest(auth, new MetaGet(), AuthHelper.join(auth.getHref(), PATH_OBJECTS + "/" + hash));
if (links == null) {
throw new F... | java |
@NotNull
public <T> T getObject(@Nullable final Meta meta, @NotNull final Links links, @NotNull final StreamHandler<T> handler) throws IOException {
final Link link = links.getLinks().get(LinkType.Download);
if (link == null) {
throw new FileNotFoundException();
}
return doRequest(link, new Obje... | java |
public static Meta generateMeta(@NotNull final StreamProvider streamProvider) throws IOException {
final MessageDigest digest = sha256();
final byte[] buffer = new byte[0x10000];
long size = 0;
try (InputStream stream = streamProvider.getStream()) {
while (true) {
int read = stream.read(bu... | java |
public boolean putObject(@NotNull final StreamProvider streamProvider, @NotNull final Meta meta, @NotNull final Links links) throws IOException {
if (links.getLinks().containsKey(LinkType.Download)) {
return false;
}
final Link uploadLink = links.getLinks().get(LinkType.Upload);
if (uploadLink == ... | java |
public long getPrice(Configuration configuration) {
long total = 0;
for (KnapsackItem knapsackItem : getKnapsackItems()) {
if (configuration.valueAt(knapsackItem.getIndex()) == 1) {
total += knapsackItem.getPrice();
}
}
return total;
} | java |
public City addDistance(City city, Integer distance) {
this.distances.put(city, distance);
return this;
} | java |
protected MoveOperation counterToOperation(int counter) {
int jobIndex = counter / (this.problem.machines - 1);
int machineIndex = counter % (this.problem.machines - 1);
if (machineIndex >= this.configuration.valueAt(jobIndex))
machineIndex++;
return this.problem.moveOperatio... | java |
public static void randomPathFast(int[] result, int size) {
//Random generator = new Random();
for (int i = 0; i < size; i++) result[i] = i;
for (int k = size - 1; k > 0; k--) {
int w = (int)Math.floor(Math.random() * (k+1));
int temp = result[w];
result[w] =... | java |
@NotNull
public CompletableFuture<Meta> upload(@NotNull final StreamProvider streamProvider) {
final CompletableFuture<Meta> future = new CompletableFuture<>();
getPool().submit(() -> {
try {
future.complete(Client.generateMeta(streamProvider));
} catch (Throwable e) {
future.compl... | java |
@NotNull
public CompletableFuture<Meta> upload(@NotNull final Meta meta, @NotNull final StreamProvider streamProvider) {
return enqueue(meta, streamProvider);
} | java |
public OETLProcessor parse(final Collection<ODocument> iBeginBlocks, final ODocument iSource, final ODocument iExtractor,
final Collection<ODocument> iTransformers, final ODocument iLoader, final Collection<ODocument> iEndBlocks,
final OCommandContext iContext) {
if (iExtractor == null)
throw new ... | java |
protected boolean fill(final Context2D context, final Attributes attr, double alpha)
{
final boolean filled = attr.hasFill();
if ((filled) || (attr.isFillShapeForSelection()))
{
alpha = alpha * attr.getFillAlpha();
if (alpha <= 0)
{
retur... | java |
protected boolean setStrokeParams(final Context2D context, final Attributes attr, double alpha, final boolean filled)
{
double width = attr.getStrokeWidth();
String color = attr.getStrokeColor();
if (null == color)
{
if (width > 0)
{
color = ... | java |
protected final void doApplyShadow(final Context2D context, final Attributes attr)
{
if ((false == isAppliedShadow()) && (attr.hasShadow()))
{
setAppliedShadow(true);
final Shadow shadow = attr.getShadow();
if (null != shadow)
{
conte... | java |
public T setDashArray(final double dash, final double... dashes)
{
getAttributes().setDashArray(new DashArray(dash, dashes));
return cast();
} | java |
@SuppressWarnings("unchecked")
@Override
public T moveUp()
{
final Node<?> parent = getParent();
if (null != parent)
{
final IContainer<?, IPrimitive<?>> container = (IContainer<?, IPrimitive<?>>) parent.asContainer();
if (null != container)
{
... | java |
@Override
public T setScale(final double x, final double y)
{
getAttributes().setScale(x, y);
return cast();
} | java |
@Override
public T setShear(final double x, final double y)
{
getAttributes().setShear(x, y);
return cast();
} | java |
@Override
public T setOffset(final double x, final double y)
{
getAttributes().setOffset(x, y);
return cast();
} | java |
public T setFillColor(final IColor color)
{
return setFillColor(null == color ? null : color.getColorString());
} | java |
public T setStrokeColor(final IColor color)
{
return setStrokeColor(null == color ? null : color.getColorString());
} | java |
private static synchronized void decrementUseCount() {
final String methodName = "decrementUseCount";
logger.entry(methodName);
--useCount;
if (useCount <= 0) {
if (bootstrap != null) {
bootstrap.group().shutdownGracefully(0, 500, TimeUnit.MILLISECONDS);
... | java |
public boolean awaitTermination(long timeout) throws InterruptedException {
final String methodName = "awaitTermination";
logger.entry(methodName);
final boolean terminated;
if (bootstrap != null) {
terminated = bootstrap.group().awaitTermination(timeout, TimeUnit.SECONDS);
... | java |
public String getDebugString()
{
final StringBuilder b = new StringBuilder();
boolean first = true;
for (final ValidationError e : m_errors)
{
if (first)
{
first = false;
}
else
{
... | java |
public static String removeJavaPackageName(String className) {
int idx = className.lastIndexOf('.');
if (idx >= 0) {
return className.substring(idx + 1);
} else {
return className;
}
} | java |
public static Class<?> loadProjectClass(Project project, String className) {
URLClassLoader classLoader = getProjectClassLoader(project);
if (classLoader != null ){
try {
return classLoader.loadClass(className);
} catch (ClassNotFoundException e) {
... | java |
@Override
protected boolean prepare(final Context2D context, final Attributes attr, final double alpha)
{
final Point2DArray points = attr.getControlPoints();
if ((points != null) && (points.size() == 3))
{
context.beginPath();
final Point2D p0 = points.get(0);
... | java |
public final ImageData copy()
{
final Context2D context = new ScratchPad(getWidth(), getHeight()).getContext();
context.putImageData(this, 0, 0);
return context.getImageData(0, 0, getWidth(), getHeight());
} | java |
@Override
protected boolean prepare(final Context2D context, final Attributes attr, final double alpha)
{
if (m_list.size() < 1)
{
if (false == parse(attr))
{
return false;
}
}
if (m_list.size() < 1)
{
return... | java |
@Override
protected boolean prepare(final Context2D context, final Attributes attr, final double alpha)
{
final double r = attr.getRadius();
if (r > 0)
{
context.beginPath();
context.arc(0, 0, r, 0, Math.PI * 2, true);
context.closePath();
... | java |
@Override
public Layer getLayer()
{
final Node<?> parent = getParent();// change, no iteration, no testing, no casting, recurses upwards to a Layer, and Layer returns itself, CYCLES!!!
if (null != parent)
{
return parent.getLayer();
}
return null;
} | java |
@Override
public Scene getScene()
{
final Node<?> parent = getParent();// change, no iteration, no testing, no casting, recurses upwards to a Scene, and Scene returns itself, CYCLES!!!
if (null != parent)
{
return parent.getScene();
}
return null;
} | java |
@Override
public Viewport getViewport()
{
final Node<?> parent = getParent();// change, no iteration, no testing, no casting, recurses upwards to a Viewport, and Viewport returns itself, CYCLES!!!
if (null != parent)
{
return parent.getViewport();
}
return nu... | java |
public static Plugin findPlugin(List<Plugin> plugins, String artifactId) {
if (plugins != null) {
for (Plugin plugin : plugins) {
String groupId = plugin.getGroupId();
if (Strings.isNullOrBlank(groupId) || Objects.equal(groupId, mavenPluginsGroupId)) {
... | java |
public static Profile findProfile(Model mavenModel, String profileId) {
List<Profile> profiles = mavenModel.getProfiles();
if (profiles != null) {
for (Profile profile : profiles) {
if (Objects.equal(profile.getId(), profileId)) {
return profile;
... | java |
public static boolean ensureMavenDependencyAdded(Project project, DependencyInstaller dependencyInstaller, String groupId, String artifactId, String scope) {
List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
for (Dependency d : dependencies) {
... | java |
public static boolean hasDependency(Model pom, String groupId, String artifactId) {
if (pom != null) {
List<org.apache.maven.model.Dependency> dependencies = pom.getDependencies();
return hasDependency(dependencies, groupId, artifactId);
}
return false;
} | java |
public static boolean hasDependency(List<org.apache.maven.model.Dependency> dependencies, String groupId, String artifactId) {
if (dependencies != null) {
for (org.apache.maven.model.Dependency dependency : dependencies) {
if (Objects.equal(groupId, dependency.getGroupId()) && Object... | java |
public static boolean hasManagedDependency(Model pom, String groupId, String artifactId) {
if (pom != null) {
DependencyManagement dependencyManagement = pom.getDependencyManagement();
if (dependencyManagement != null) {
return hasDependency(dependencyManagement.getDepend... | java |
public static boolean updatePomProperty(Properties properties, String name, Object value, boolean updated) {
if (value != null) {
Object oldValue = properties.get(name);
if (!Objects.equal(oldValue, value)) {
getLOG().debug("Updating pom.xml property: " + name + " to " + ... | java |
@Override
protected boolean prepare(final Context2D context, final Attributes attr, final double alpha)
{
final double w = attr.getWidth();
final double h = attr.getHeight();
if ((w > 0) && (h > 0))
{
context.beginPath();
context.ellipse(0, 0, w / 2, h ... | java |
public static Result loadCamelComponentDetails(CamelCatalog camelCatalog, String camelComponentName, CamelComponentDetails details) {
String json = camelCatalog.componentJSonSchema(camelComponentName);
if (json == null) {
return Results.fail("Could not find catalog entry for component name: ... | java |
public static Class<Object> loadValidInputTypes(String javaType, String type) {
// we have generics in the javatype, if so remove it so its loadable from a classloader
int idx = javaType.indexOf('<');
if (idx > 0) {
javaType = javaType.substring(0, idx);
}
try {
... | java |
public static Class getPrimitiveWrapperClassType(String name) {
if ("string".equals(name)) {
return String.class;
} else if ("boolean".equals(name)) {
return Boolean.class;
} else if ("integer".equals(name)) {
return Integer.class;
} else if ("number".... | java |
public void addValidationError(String message) {
messages.add(new UIMessageDTO(message, null, UIMessage.Severity.ERROR));
valid = false;
canExecute = false;
} | java |
public Object marshalRootElement() {
if (justRoutes) {
RoutesDefinition routes = new RoutesDefinition();
routes.setRoutes(contextElement.getRoutes());
return routes;
} else {
return contextElement;
}
} | java |
public Set<String> endpointUris() {
try {
// we must use reflection for now until Camel supports the getEndpoints() method
// https://issues.apache.org/jira/browse/CAMEL-3644
// ...
// the above is no longer valid since Camel 2.7.0
List<CamelEndpointFa... | java |
protected boolean isValidCommandName(String name) {
if (Strings.isNullOrBlank(name) || ignoreCommands.contains(name)) {
return false;
}
for (String prefix : ignoreCommandPrefixes) {
if (name.startsWith(prefix)) {
return false;
}
}
... | java |
public static String mandatoryAttributeValue(Map<Object, Object> attributeMap, String name) {
Object value = attributeMap.get(name);
if (value != null) {
String text = value.toString();
if (!Strings.isBlank(text)) {
return text;
}
}
thr... | java |
public void validateFileDoesNotExist(UIInput<String> directory, UIInput<String> fileName, UIValidationContext validator) {
String resourcePath = CamelXmlHelper.createFileName(directory, fileName);
if (files.contains(resourcePath)) {
validator.addValidationError(fileName, "A file with that na... | java |
@Override
protected boolean prepare(final Context2D context, final Attributes attr, final double alpha)
{
final double r = attr.getRadius();
final double beg = attr.getStartAngle();
final double end = attr.getEndAngle();
if (r > 0)
{
context.beginPath();
... | java |
private void writeToNetwork(EngineConnection engineConnection) {
final String methodName = "writeToNetwork";
logger.entry(this, methodName, engineConnection);
if (engineConnection.transport.pending() > 0) {
ByteBuffer head = engineConnection.transport.head();
int amount = he... | java |
private void resetReceiveIdleTimer(Event event) {
final String methodName = "resetReceiveIdleTimer";
logger.entry(this, methodName, event);
if (receiveScheduledFuture != null) {
receiveScheduledFuture.cancel(false);
}
final Transport transport = event.getTransport()... | java |
private WiresMagnet getCloserMagnet(final WiresShape shape, final WiresContainer parent, final boolean allowOverlap)
{
final WiresShape parentShape = (WiresShape) parent;
final MagnetManager.Magnets magnets = parentShape.getMagnets();
final Point2D shapeLocation = shape.getComputedLocation()... | java |
public static void stop() {
final ILoggerFactory loggerFactory = org.slf4j.LoggerFactory.getILoggerFactory();
if (loggerFactory instanceof LoggerContext) {
final LoggerContext context = (LoggerContext) loggerFactory;
context.stop();
}
setup.getAndSet(false);
} | java |
@Override
public void move(final double dx, final double dy, final boolean midPointsOnly, final boolean moveLinePoints)
{
final IControlHandleList handles = m_connector.getPointHandles();
int start = 0;
int end = handles.size();
if (midPointsOnly)
{
if (m_c... | java |
public static String getVersion() {
String version = "unknown";
final URLClassLoader cl = (URLClassLoader)cclass.getClassLoader();
try {
final URL url = cl.findResource("META-INF/MANIFEST.MF");
final Manifest manifest = new Manifest(url.openStream());
for (Entry<Object,Object> entry : mani... | java |
public static String after(String text, String after) {
if (!text.contains(after)) {
return null;
}
return text.substring(text.indexOf(after) + after.length());
} | java |
public static String before(String text, String before) {
if (!text.contains(before)) {
return null;
}
return text.substring(0, text.indexOf(before));
} | java |
public static String between(String text, String after, String before) {
text = after(text, after);
if (text == null) {
return null;
}
return before(text, before);
} | java |
public static List<InputComponent> addInputComponents(UIBuilder builder, InputComponent... components) {
List<InputComponent> inputComponents = new ArrayList<>();
for (InputComponent component : components) {
builder.add(component);
inputComponents.add(component);
}
... | java |
public static <T> void setInitialComponentValue(UIInput<T> inputComponent, T value) {
if (value != null) {
inputComponent.setValue(value);
}
} | java |
public static String createCommitMessage(String name, ExecutionRequest executionRequest) {
StringBuilder builder = new StringBuilder(name);
List<Map<String, Object>> inputList = executionRequest.getInputList();
for (Map<String, Object> map : inputList) {
Set<Map.Entry<String, Object>... | java |
public static ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
return mapper;
} | java |
public static String asTitleCase(String text) {
StringBuilder sb = new StringBuilder();
boolean next = true;
for (char c : text.toCharArray()) {
if (Character.isSpaceChar(c)) {
next = true;
} else if (next) {
c = Character.toTitleCase(c);
... | java |
public static boolean isDefaultValue(CamelCatalog camelCatalog, String scheme, String key, String value) {
// use the camel catalog
String json = camelCatalog.componentJSonSchema(scheme);
if (json == null) {
throw new IllegalArgumentException("Could not find catalog entry for compone... | java |
public static boolean isModelDefaultValue(CamelCatalog camelCatalog, String modelName, String key, String value) {
// use the camel catalog
String json = camelCatalog.modelJSonSchema(modelName);
if (json == null) {
throw new IllegalArgumentException("Could not find catalog entry for ... | java |
public static String getModelJavaType(CamelCatalog camelCatalog, String modelName) {
// use the camel catalog
String json = camelCatalog.modelJSonSchema(modelName);
if (json == null) {
throw new IllegalArgumentException("Could not find catalog entry for model name: " + modelName);
... | java |
public static boolean isModelSupportOutput(CamelCatalog camelCatalog, String modelName) {
// use the camel catalog
String json = camelCatalog.modelJSonSchema(modelName);
if (json == null) {
throw new IllegalArgumentException("Could not find catalog entry for model name: " + modelName... | java |
public static boolean isComponentConsumerOnly(CamelCatalog camelCatalog, String scheme) {
// use the camel catalog
String json = camelCatalog.componentJSonSchema(scheme);
if (json == null) {
return false;
}
List<Map<String, String>> data = JSonSchemaHelper.parseJsonS... | java |
public GitContext commitMessage(String message) {
if (commitMessage.length() == 0) {
commitMessage.append(message + "\n");
} else {
commitMessage.append("\n- " + message);
}
return this;
} | java |
public List<Certificate> getCertificates() throws CertificateException, IOException {
final String methodName = "getCertificates";
logger.entry(this, methodName);
final String fileData = getPemFileData();
final List<ByteBuf> certDataList = new ArrayList<ByteBuf>();
fina... | java |
private String getPemFileData() throws IOException {
final String methodName = "getPemFileData";
logger.entry(this, methodName);
if (pemFileData != null) {
logger.exit(this, methodName, pemFileData);
return pemFileData;
}
final StringBuil... | java |
public static <T> T newInstance(Class<T> type) {
try {
return type.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java |
public static boolean hasMethodWithAnnotation(Class<?> type,
Class<? extends Annotation> annotationType,
boolean checkMetaAnnotations) {
try {
do {
Method[] methods = type.getDeclaredM... | java |
public static boolean hasAnnotation(AnnotatedElement elem, Class<? extends Annotation> annotationType,
boolean checkMetaAnnotations) {
if (elem.isAnnotationPresent(annotationType)) {
return true;
}
if (checkMetaAnnotations) {
for (A... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.