id
stringlengths
7
14
text
stringlengths
1
106k
2272670_1
@Factory public static Matcher<Object> isApproved() throws IOException { final StackTraceElement trace = StackUtils .getCallingTestMethodStackTraceElement(); final String methodName = trace.getMethodName(); final String className = getClassName(trace); final Class<?> clazz = getClassObject(t...
2272670_2
@Factory public static Matcher<Object> isApproved() throws IOException { final StackTraceElement trace = StackUtils .getCallingTestMethodStackTraceElement(); final String methodName = trace.getMethodName(); final String className = getClassName(trace); final Class<?> clazz = getClassObject(t...
2272670_3
@Factory public static Matcher<Object> isApproved() throws IOException { final StackTraceElement trace = StackUtils .getCallingTestMethodStackTraceElement(); final String methodName = trace.getMethodName(); final String className = getClassName(trace); final Class<?> clazz = getClassObject(t...
2272670_4
@Factory public static Matcher<Object> isApproved() throws IOException { final StackTraceElement trace = StackUtils .getCallingTestMethodStackTraceElement(); final String methodName = trace.getMethodName(); final String className = getClassName(trace); final Class<?> clazz = getClassObject(t...
2272670_5
public static ImageComparisonResult compare(Object actual, Object reference) { final BufferedImage actualImage = ImageRenderer.getImage(actual); if (reference == null) { return new NoReferenceImageResult(actualImage); } final BufferedImage referenceImage = ImageRenderer.getImage(reference); ...
2272670_6
public static ImageComparisonResult compare(Object actual, Object reference) { final BufferedImage actualImage = ImageRenderer.getImage(actual); if (reference == null) { return new NoReferenceImageResult(actualImage); } final BufferedImage referenceImage = ImageRenderer.getImage(reference); ...
2272670_7
public static ImageComparisonResult compare(Object actual, Object reference) { final BufferedImage actualImage = ImageRenderer.getImage(actual); if (reference == null) { return new NoReferenceImageResult(actualImage); } final BufferedImage referenceImage = ImageRenderer.getImage(reference); ...
2272670_8
public static ImageComparisonResult compare(Object actual, Object reference) { final BufferedImage actualImage = ImageRenderer.getImage(actual); if (reference == null) { return new NoReferenceImageResult(actualImage); } final BufferedImage referenceImage = ImageRenderer.getImage(reference); ...
2272670_9
public static ImageComparisonResult compare(Object actual, Object reference) { final BufferedImage actualImage = ImageRenderer.getImage(actual); if (reference == null) { return new NoReferenceImageResult(actualImage); } final BufferedImage referenceImage = ImageRenderer.getImage(reference); ...
2287347_0
public int getOsmState(Granularity granularity) { String result = restOperations.getForObject(STATE_URL, String.class, granularity.name()); Pattern pattern = Pattern.compile(".*sequenceNumber=(\\d*).*", Pattern.MULTILINE | Pattern.DOTALL); Matcher matcher = pattern.matcher(result); if (matcher.matches()) { String...
2287347_1
public OsmChange getOsmChange(String url) { ResponseEntity<OsmChange> entity = restOperations.getForEntity(url, OsmChange.class); return entity.getBody(); }
2287347_2
public static State split(int state) { return new State((int)(Math.floor(state / 1000000.0) % 1000), (int)(Math.floor(state / 1000.0) % 1000), state % 1000); }
2287347_3
public int getElevation(double lon, double lat) { int key = (((int)lat) + 90) * 360 + (((int)lon) + 180); SrtmTile srtmTile = tileMap.get(key); return srtmTile.getElevation(lon, lat); }
2287347_4
public boolean hasData(double lon, double lat) { return (int)lon == this.lon && (int)lat == this.lat; }
2287347_5
public int getElevation(double lon, double lat) { int x = (int)Math.round((lon - this.lon) * 1200); int y = (int)Math.round((lat - this.lat) * 1200); int pos = (1200 - y) * (1201 * 2) + (x * 2); return getBuffer().getShort(pos); }
2287347_6
public ConnectableSegment createSegment(Member member) { Way way = member.getWay(); if (RoundaboutService.isRoundabout(way)) return new RoundaboutWay(way.getNodes()); String memberRole = member.getRole(); if ("forward".equals(memberRole)) return createFixedSegment(way, false); else if ("backward".equals(member...
2287347_7
public ConnectableSegment createSegment(Member member) { Way way = member.getWay(); if (RoundaboutService.isRoundabout(way)) return new RoundaboutWay(way.getNodes()); String memberRole = member.getRole(); if ("forward".equals(memberRole)) return createFixedSegment(way, false); else if ("backward".equals(member...
2287347_8
@Override public ConnectableNode getEndpointNodes() { return endpointNodes; }
2287347_9
@Override public SegmentNodes getSegmentNodes() { return new SegmentNodes(wayNodes.get(0), wayNodes.get(wayNodes.size() - 1)); }
2293442_0
@Override public boolean equals(Object obj) { boolean result = false; if (obj == this) { result = true; } else if ((obj != null) && (getClass().equals(obj.getClass()))) { Identifier other = (Identifier) obj; EqualsBuilder eqbuilder = new EqualsBuilder(); eqbuilder.append(getR...
2293442_1
public Map<String, String> parse(ContentParserConfig config, byte[] input) throws XMLParserException, XPathHelperException { Map<String, String> result = new HashMap<String, String>(); OMElement node = XMLParser.bytesToOM(input); String[][] prefixUris = config.toPrefixURIArrays(); String[] prefi...
2293442_2
protected Map<String, String> createReplaceVariables(Document document) throws XMLParserException, XPathHelperException { ContentParser parser = getContentParser(); ContentParserConfig cfg = getContentParserConfig(); Map<String, String> result = parser.parse(cfg, document.getContent()); // //// ...
2293442_3
@Override public XDSPnRMessage map(SubjectIdentifier patientId, Document document) throws Exception { Map<String, String> repl = createReplaceVariables(document); validate(patientId, document, repl); for (Map.Entry<String, String> entry : repl.entrySet()) { // sanitize values (& becomes &amp...
2293442_4
public static boolean isUUID(String uuidstr) { boolean result = false; try { UUID.fromString(uuidstr); result = true; } catch (IllegalArgumentException e) { // don't care } return result; }
2293442_5
public static String toOID(UUID uuid) { return toOID(uuid, OID_ROOT); }
2296450_0
public MemcachedClientIF createMemcachedClient() throws IOException { if (this.bean == null) { throw new RuntimeException("The MemcachedConnectionBean must be defined!"); } final List<InetSocketAddress> addrs = AddrUtil.getAddresses(this.bean.getNodeList()); final ConnectionFactory connectionFactory = this.bean.i...
2296450_1
protected List<Object> getKeyObjects(final int keyIndex, final Object returnValue, final JoinPoint jp, final Method methodToCache) throws Exception { final Object keyObject = keyIndex == -1 ? validateReturnValueAsKeyObject(r...
2296450_2
protected void updateCache(final List<String> cacheKeys, final List<Object> returnList, final Method methodToCache, final AnnotationData annotationData) { if (returnList.size() != cacheKeys.size()) { throw new InvalidAnnotationException...
2296450_3
static void populateAssignedKey(final AnnotationData data, final Annotation annotation, final Class expectedAnnotationClass, final String targetMethodName) throws NoSuchMethodException, Illega...
2296450_4
static void populateNamespace(final AnnotationData data, final Annotation annotation, final Class expectedAnnotationClass, final String targetMethodName) throws NoSuchMethodException, IllegalAccessE...
2296450_5
static void populateExpiration(final AnnotationData data, final Annotation annotation, final Class expectedAnnotationClass, final String targetMethodName) throws NoSuchMethodException, IllegalAcc...
2296450_6
static void populateClassName(final AnnotationData data, final Annotation annotation, final Class expectedAnnotationClass) { if (annotation == null) { throw new InvalidParameterException(String.format( "No annotation of type [%s] ...
2296450_7
static void populateKeyIndexAndBeanName(final AnnotationData data, final Class expectedAnnotationClass, final Method targetMethod) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (ASSIGNS.contains(...
2296450_8
static void populateDataIndexFromAnnotations(final AnnotationData data, final Class expectedAnnotationClass, final Method targetMethod) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (!UPDATES.c...
2296450_9
protected String getObjectId(final int keyIndex, final Object returnValue, final JoinPoint jp, final Method methodToCache) throws Exception { final Object keyObject = keyIndex == -1 ? validateReturnValueAsKeyObject(returnVa...
229738_10
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_11
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_12
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_13
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_14
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_15
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_16
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_17
@Override public boolean accepts(Type containerType) { Class<?> erasedType = getCollectionType(containerType); final boolean hasCollector = collectors.containsKey(erasedType); return (hasCollector || hasDefaultImplementationWithCollector(erasedType)) && containerType instanceof ParameterizedType...
229738_18
@Override public boolean accepts(Type containerType) { Class<?> erasedType = getCollectionType(containerType); final boolean hasCollector = collectors.containsKey(erasedType); return (hasCollector || hasDefaultImplementationWithCollector(erasedType)) && containerType instanceof ParameterizedType...
229738_19
@Override public boolean accepts(Type containerType) { Class<?> erasedType = getCollectionType(containerType); final boolean hasCollector = collectors.containsKey(erasedType); return (hasCollector || hasDefaultImplementationWithCollector(erasedType)) && containerType instanceof ParameterizedType...
229738_20
@Override public String render(String template, StatementContext ctx) { StringSubstitutor substitutor = new StringSubstitutor(ctx.getAttributes()); customizer.accept(substitutor); return substitutor.replace(template); }
229738_21
public static <T> Collector<T, ?, Optional<T>> toOptional() { return toOptional(Optional::empty, Optional::of); }
229738_22
public static Collector<Integer, ?, OptionalInt> toOptionalInt() { return toOptional(OptionalInt::empty, OptionalInt::of); }
229738_23
public static Collector<Long, ?, OptionalLong> toOptionalLong() { return toOptional(OptionalLong::empty, OptionalLong::of); }
229738_24
public static Collector<Double, ?, OptionalDouble> toOptionalDouble() { return toOptional(OptionalDouble::empty, OptionalDouble::of); }
229738_25
public static ParsedParameters named(List<String> names) { if (names.contains(ParsedSql.POSITIONAL_PARAM)) { throw new IllegalArgumentException("Named parameters " + "list must not contain positional parameter " + "\"" + ParsedSql.POSITIONAL_PARAM + "\""); } return new Parsed...
229738_26
public <T> Optional<ColumnMapper<T>> findColumnMapperFor(Class<T> type) { return getConfig(ColumnMappers.class).findFor(type); }
229738_27
public <T> Optional<ColumnMapper<T>> findColumnMapperFor(Class<T> type) { return getConfig(ColumnMappers.class).findFor(type); }
229738_28
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_29
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_30
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_31
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_32
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_33
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_34
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_35
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_36
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_37
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_38
@Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }
229738_39
public int[] execute() { final List<String> statements = getStatements(); Batch b = handle.createBatch(); statements.forEach(b::add); return b.execute(); }
229738_40
public int[] execute() { final List<String> statements = getStatements(); Batch b = handle.createBatch(); statements.forEach(b::add); return b.execute(); }
229738_41
public int[] execute() { final List<String> statements = getStatements(); Batch b = handle.createBatch(); statements.forEach(b::add); return b.execute(); }
229738_42
public void executeAsSeparateStatements() { for (String s : getStatements()) { handle.execute(s); } }
229738_43
public void executeAsSeparateStatements() { for (String s : getStatements()) { handle.execute(s); } }
229738_44
public int[] execute() { final List<String> statements = getStatements(); Batch b = handle.createBatch(); statements.forEach(b::add); return b.execute(); }
229738_45
public int[] execute() { try { return internalBatchExecute().updateCounts; } finally { getContext().close(); } }
229738_46
void bind(Binding binding) { if (params.isPositional()) { bindPositional(binding); } else { bindNamed(binding); } }
229738_47
void bind(Binding binding) { if (params.isPositional()) { bindPositional(binding); } else { bindNamed(binding); } }
229738_48
void bind(Binding binding) { if (params.isPositional()) { bindPositional(binding); } else { bindNamed(binding); } }
229738_49
void bind(Binding binding) { if (params.isPositional()) { bindPositional(binding); } else { bindNamed(binding); } }
229738_50
void bind(Binding binding) { if (params.isPositional()) { bindPositional(binding); } else { bindNamed(binding); } }
229738_51
void bind(Binding binding) { if (params.isPositional()) { bindPositional(binding); } else { bindNamed(binding); } }
229738_52
void bind(Binding binding) { if (params.isPositional()) { bindPositional(binding); } else { bindNamed(binding); } }
229738_53
void bind(Binding binding) { if (params.isPositional()) { bindPositional(binding); } else { bindNamed(binding); } }
229738_54
public void define(String key, Object value) { getConfig(SqlStatements.class).define(key, value); }
229738_55
@SuppressWarnings("PMD.UseStringBufferForStringAppends") protected static String limit(String s, int len) { if (s == null) { return null; } String truncated = s.substring(0, Math.min(len, s.length())); boolean isTruncated = len < s.length(); if (isTruncated) { truncated += "[...]"; ...
229738_56
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_57
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_58
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_59
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_60
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_61
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_62
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_63
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_64
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_65
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_66
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_67
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_68
@Override public String render(String template, StatementContext ctx) { MessageFormat msgFormat = new MessageFormat(template); validateKeys(ctx.getAttributes().keySet(), msgFormat.getFormats().length); Object[] args = ctx.getAttributes() .entrySet() .stream() .map(x -> new AbstractMa...
229738_69
public <R, X extends Exception> R inTransaction(HandleCallback<R, X> callback) throws X { return isInTransaction() ? callback.withHandle(this) : transactions.inTransaction(this, callback); }
229738_70
public boolean isClosed() { return closed; }
229738_71
public int execute(String sql, Object... args) { try (Update stmt = createUpdate(sql)) { int position = 0; for (Object arg : args) { stmt.bind(position++, arg); } return stmt.execute(); } }
229738_72
public void setTransactionIsolation(TransactionIsolationLevel level) { if (level != TransactionIsolationLevel.UNKNOWN) { setTransactionIsolation(level.intValue()); } }
229738_73
public <T> T getColumn(String column, Class<T> type) { return type.cast(getColumn(column, (Type) type)); }
229738_74
public <T> T getColumn(String column, Class<T> type) { return type.cast(getColumn(column, (Type) type)); }