id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
17,000
line/armeria
core/src/main/java/com/linecorp/armeria/client/ClientConnectionTimingsBuilder.java
ClientConnectionTimingsBuilder.socketConnectEnd
public ClientConnectionTimingsBuilder socketConnectEnd() { checkState(socketConnectStartTimeMicros >= 0, "socketConnectStart() is not called yet."); checkState(!socketConnectEndSet, "socketConnectEnd() is already called."); socketConnectEndNanos = System.nanoTime(); socketConnectEndSet = true; return this; }
java
public ClientConnectionTimingsBuilder socketConnectEnd() { checkState(socketConnectStartTimeMicros >= 0, "socketConnectStart() is not called yet."); checkState(!socketConnectEndSet, "socketConnectEnd() is already called."); socketConnectEndNanos = System.nanoTime(); socketConnectEndSet = true; return this; }
[ "public", "ClientConnectionTimingsBuilder", "socketConnectEnd", "(", ")", "{", "checkState", "(", "socketConnectStartTimeMicros", ">=", "0", ",", "\"socketConnectStart() is not called yet.\"", ")", ";", "checkState", "(", "!", "socketConnectEndSet", ",", "\"socketConnectEnd() is already called.\"", ")", ";", "socketConnectEndNanos", "=", "System", ".", "nanoTime", "(", ")", ";", "socketConnectEndSet", "=", "true", ";", "return", "this", ";", "}" ]
Sets the time when the client ended to connect to a remote peer. @throws IllegalStateException if {@link #socketConnectStart()} is not invoked before calling this.
[ "Sets", "the", "time", "when", "the", "client", "ended", "to", "connect", "to", "a", "remote", "peer", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/client/ClientConnectionTimingsBuilder.java#L82-L88
17,001
line/armeria
core/src/main/java/com/linecorp/armeria/internal/PathAndQuery.java
PathAndQuery.firstPathComponentContainsColon
private static boolean firstPathComponentContainsColon(Bytes path) { final int length = path.length; for (int i = 1; i < length; i++) { final byte b = path.data[i]; if (b == '/') { break; } if (b == ':') { return true; } } return false; }
java
private static boolean firstPathComponentContainsColon(Bytes path) { final int length = path.length; for (int i = 1; i < length; i++) { final byte b = path.data[i]; if (b == '/') { break; } if (b == ':') { return true; } } return false; }
[ "private", "static", "boolean", "firstPathComponentContainsColon", "(", "Bytes", "path", ")", "{", "final", "int", "length", "=", "path", ".", "length", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "length", ";", "i", "++", ")", "{", "final", "byte", "b", "=", "path", ".", "data", "[", "i", "]", ";", "if", "(", "b", "==", "'", "'", ")", "{", "break", ";", "}", "if", "(", "b", "==", "'", "'", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
According to RFC 3986 section 3.3, path can contain a colon, except the first segment. <p>Should allow the asterisk character in the path, query, or fragment components of a URL(RFC2396). @see <a href="https://tools.ietf.org/html/rfc3986#section-3.3">RFC 3986, section 3.3</a>
[ "According", "to", "RFC", "3986", "section", "3", ".", "3", "path", "can", "contain", "a", "colon", "except", "the", "first", "segment", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/internal/PathAndQuery.java#L394-L406
17,002
line/armeria
core/src/main/java/com/linecorp/armeria/internal/logging/CountingSampler.java
CountingSampler.mod
static int mod(int dividend, int divisor) { int result = dividend % divisor; return result >= 0 ? result : divisor + result; }
java
static int mod(int dividend, int divisor) { int result = dividend % divisor; return result >= 0 ? result : divisor + result; }
[ "static", "int", "mod", "(", "int", "dividend", ",", "int", "divisor", ")", "{", "int", "result", "=", "dividend", "%", "divisor", ";", "return", "result", ">=", "0", "?", "result", ":", "divisor", "+", "result", ";", "}" ]
Returns a non-negative mod.
[ "Returns", "a", "non", "-", "negative", "mod", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/internal/logging/CountingSampler.java#L101-L104
17,003
line/armeria
thrift/src/main/java/com/linecorp/armeria/server/thrift/ThriftDocServicePlugin.java
ThriftDocServicePlugin.loadDocStrings
@Override public Map<String, String> loadDocStrings(Set<ServiceConfig> serviceConfigs) { return serviceConfigs.stream() .flatMap(c -> c.service().as(THttpService.class).get().entries().values().stream()) .flatMap(entry -> entry.interfaces().stream().map(Class::getClassLoader)) .flatMap(loader -> docstringExtractor.getAllDocStrings(loader) .entrySet().stream()) .collect(toImmutableMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a)); }
java
@Override public Map<String, String> loadDocStrings(Set<ServiceConfig> serviceConfigs) { return serviceConfigs.stream() .flatMap(c -> c.service().as(THttpService.class).get().entries().values().stream()) .flatMap(entry -> entry.interfaces().stream().map(Class::getClassLoader)) .flatMap(loader -> docstringExtractor.getAllDocStrings(loader) .entrySet().stream()) .collect(toImmutableMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a)); }
[ "@", "Override", "public", "Map", "<", "String", ",", "String", ">", "loadDocStrings", "(", "Set", "<", "ServiceConfig", ">", "serviceConfigs", ")", "{", "return", "serviceConfigs", ".", "stream", "(", ")", ".", "flatMap", "(", "c", "->", "c", ".", "service", "(", ")", ".", "as", "(", "THttpService", ".", "class", ")", ".", "get", "(", ")", ".", "entries", "(", ")", ".", "values", "(", ")", ".", "stream", "(", ")", ")", ".", "flatMap", "(", "entry", "->", "entry", ".", "interfaces", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "Class", "::", "getClassLoader", ")", ")", ".", "flatMap", "(", "loader", "->", "docstringExtractor", ".", "getAllDocStrings", "(", "loader", ")", ".", "entrySet", "(", ")", ".", "stream", "(", ")", ")", ".", "collect", "(", "toImmutableMap", "(", "Map", ".", "Entry", "::", "getKey", ",", "Map", ".", "Entry", "::", "getValue", ",", "(", "a", ",", "b", ")", "->", "a", ")", ")", ";", "}" ]
Methods related with extracting documentation strings.
[ "Methods", "related", "with", "extracting", "documentation", "strings", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/thrift/src/main/java/com/linecorp/armeria/server/thrift/ThriftDocServicePlugin.java#L449-L457
17,004
line/armeria
core/src/main/java/com/linecorp/armeria/server/cors/CorsServiceBuilder.java
CorsServiceBuilder.forOrigins
public static CorsServiceBuilder forOrigins(String... origins) { requireNonNull(origins, "origins"); if (Arrays.asList(origins).contains(ANY_ORIGIN)) { if (origins.length > 1) { logger.warn("Any origin (*) has been already included. Other origins ({}) will be ignored.", Arrays.stream(origins).filter(c -> !ANY_ORIGIN.equals(c)) .collect(Collectors.joining(","))); } return forAnyOrigin(); } return new CorsServiceBuilder(origins); }
java
public static CorsServiceBuilder forOrigins(String... origins) { requireNonNull(origins, "origins"); if (Arrays.asList(origins).contains(ANY_ORIGIN)) { if (origins.length > 1) { logger.warn("Any origin (*) has been already included. Other origins ({}) will be ignored.", Arrays.stream(origins).filter(c -> !ANY_ORIGIN.equals(c)) .collect(Collectors.joining(","))); } return forAnyOrigin(); } return new CorsServiceBuilder(origins); }
[ "public", "static", "CorsServiceBuilder", "forOrigins", "(", "String", "...", "origins", ")", "{", "requireNonNull", "(", "origins", ",", "\"origins\"", ")", ";", "if", "(", "Arrays", ".", "asList", "(", "origins", ")", ".", "contains", "(", "ANY_ORIGIN", ")", ")", "{", "if", "(", "origins", ".", "length", ">", "1", ")", "{", "logger", ".", "warn", "(", "\"Any origin (*) has been already included. Other origins ({}) will be ignored.\"", ",", "Arrays", ".", "stream", "(", "origins", ")", ".", "filter", "(", "c", "->", "!", "ANY_ORIGIN", ".", "equals", "(", "c", ")", ")", ".", "collect", "(", "Collectors", ".", "joining", "(", "\",\"", ")", ")", ")", ";", "}", "return", "forAnyOrigin", "(", ")", ";", "}", "return", "new", "CorsServiceBuilder", "(", "origins", ")", ";", "}" ]
Creates a new builder with the specified origins.
[ "Creates", "a", "new", "builder", "with", "the", "specified", "origins", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/cors/CorsServiceBuilder.java#L80-L91
17,005
line/armeria
zookeeper/src/main/java/com/linecorp/armeria/server/zookeeper/ZooKeeperUpdatingListenerBuilder.java
ZooKeeperUpdatingListenerBuilder.connectTimeout
public ZooKeeperUpdatingListenerBuilder connectTimeout(Duration connectTimeout) { requireNonNull(connectTimeout, "connectTimeout"); checkArgument(!connectTimeout.isZero() && !connectTimeout.isNegative(), "connectTimeout: %s (expected: > 0)", connectTimeout); return connectTimeoutMillis(connectTimeout.toMillis()); }
java
public ZooKeeperUpdatingListenerBuilder connectTimeout(Duration connectTimeout) { requireNonNull(connectTimeout, "connectTimeout"); checkArgument(!connectTimeout.isZero() && !connectTimeout.isNegative(), "connectTimeout: %s (expected: > 0)", connectTimeout); return connectTimeoutMillis(connectTimeout.toMillis()); }
[ "public", "ZooKeeperUpdatingListenerBuilder", "connectTimeout", "(", "Duration", "connectTimeout", ")", "{", "requireNonNull", "(", "connectTimeout", ",", "\"connectTimeout\"", ")", ";", "checkArgument", "(", "!", "connectTimeout", ".", "isZero", "(", ")", "&&", "!", "connectTimeout", ".", "isNegative", "(", ")", ",", "\"connectTimeout: %s (expected: > 0)\"", ",", "connectTimeout", ")", ";", "return", "connectTimeoutMillis", "(", "connectTimeout", ".", "toMillis", "(", ")", ")", ";", "}" ]
Sets the connect timeout. @param connectTimeout the connect timeout @throws IllegalStateException if this builder is constructed with {@link #ZooKeeperUpdatingListenerBuilder(CuratorFramework, String)}
[ "Sets", "the", "connect", "timeout", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/zookeeper/src/main/java/com/linecorp/armeria/server/zookeeper/ZooKeeperUpdatingListenerBuilder.java#L114-L119
17,006
line/armeria
zookeeper/src/main/java/com/linecorp/armeria/server/zookeeper/ZooKeeperUpdatingListenerBuilder.java
ZooKeeperUpdatingListenerBuilder.sessionTimeout
public ZooKeeperUpdatingListenerBuilder sessionTimeout(Duration sessionTimeout) { requireNonNull(sessionTimeout, "sessionTimeout"); checkArgument(!sessionTimeout.isZero() && !sessionTimeout.isNegative(), "sessionTimeout: %s (expected: > 0)", sessionTimeout); return sessionTimeoutMillis(sessionTimeout.toMillis()); }
java
public ZooKeeperUpdatingListenerBuilder sessionTimeout(Duration sessionTimeout) { requireNonNull(sessionTimeout, "sessionTimeout"); checkArgument(!sessionTimeout.isZero() && !sessionTimeout.isNegative(), "sessionTimeout: %s (expected: > 0)", sessionTimeout); return sessionTimeoutMillis(sessionTimeout.toMillis()); }
[ "public", "ZooKeeperUpdatingListenerBuilder", "sessionTimeout", "(", "Duration", "sessionTimeout", ")", "{", "requireNonNull", "(", "sessionTimeout", ",", "\"sessionTimeout\"", ")", ";", "checkArgument", "(", "!", "sessionTimeout", ".", "isZero", "(", ")", "&&", "!", "sessionTimeout", ".", "isNegative", "(", ")", ",", "\"sessionTimeout: %s (expected: > 0)\"", ",", "sessionTimeout", ")", ";", "return", "sessionTimeoutMillis", "(", "sessionTimeout", ".", "toMillis", "(", ")", ")", ";", "}" ]
Sets the session timeout. @param sessionTimeout the session timeout @throws IllegalStateException if this builder is constructed with {@link #ZooKeeperUpdatingListenerBuilder(CuratorFramework, String)}
[ "Sets", "the", "session", "timeout", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/zookeeper/src/main/java/com/linecorp/armeria/server/zookeeper/ZooKeeperUpdatingListenerBuilder.java#L145-L150
17,007
line/armeria
zookeeper/src/main/java/com/linecorp/armeria/server/zookeeper/ZooKeeperUpdatingListener.java
ZooKeeperUpdatingListener.of
public static ZooKeeperUpdatingListener of(String zkConnectionStr, String zNodePath) { return new ZooKeeperUpdatingListenerBuilder(zkConnectionStr, zNodePath).build(); }
java
public static ZooKeeperUpdatingListener of(String zkConnectionStr, String zNodePath) { return new ZooKeeperUpdatingListenerBuilder(zkConnectionStr, zNodePath).build(); }
[ "public", "static", "ZooKeeperUpdatingListener", "of", "(", "String", "zkConnectionStr", ",", "String", "zNodePath", ")", "{", "return", "new", "ZooKeeperUpdatingListenerBuilder", "(", "zkConnectionStr", ",", "zNodePath", ")", ".", "build", "(", ")", ";", "}" ]
Creates a ZooKeeper server listener, which registers server into ZooKeeper. <p>If you need a fully customized {@link ZooKeeperUpdatingListener} instance, use {@link ZooKeeperUpdatingListenerBuilder} instead. @param zkConnectionStr ZooKeeper connection string @param zNodePath ZooKeeper node path(under which this server will be registered)
[ "Creates", "a", "ZooKeeper", "server", "listener", "which", "registers", "server", "into", "ZooKeeper", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/zookeeper/src/main/java/com/linecorp/armeria/server/zookeeper/ZooKeeperUpdatingListener.java#L48-L50
17,008
line/armeria
core/src/main/java/com/linecorp/armeria/server/HttpServerHandler.java
HttpServerHandler.setContentLength
private static void setContentLength(HttpRequest req, HttpHeaders headers, int contentLength) { // https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 // prohibits to send message body for below cases. // and in those cases, content should be empty. if (req.method() == HttpMethod.HEAD || ArmeriaHttpUtil.isContentAlwaysEmpty(headers.status())) { return; } headers.setInt(HttpHeaderNames.CONTENT_LENGTH, contentLength); }
java
private static void setContentLength(HttpRequest req, HttpHeaders headers, int contentLength) { // https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 // prohibits to send message body for below cases. // and in those cases, content should be empty. if (req.method() == HttpMethod.HEAD || ArmeriaHttpUtil.isContentAlwaysEmpty(headers.status())) { return; } headers.setInt(HttpHeaderNames.CONTENT_LENGTH, contentLength); }
[ "private", "static", "void", "setContentLength", "(", "HttpRequest", "req", ",", "HttpHeaders", "headers", ",", "int", "contentLength", ")", "{", "// https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4", "// prohibits to send message body for below cases.", "// and in those cases, content should be empty.", "if", "(", "req", ".", "method", "(", ")", "==", "HttpMethod", ".", "HEAD", "||", "ArmeriaHttpUtil", ".", "isContentAlwaysEmpty", "(", "headers", ".", "status", "(", ")", ")", ")", "{", "return", ";", "}", "headers", ".", "setInt", "(", "HttpHeaderNames", ".", "CONTENT_LENGTH", ",", "contentLength", ")", ";", "}" ]
Sets the 'content-length' header to the response.
[ "Sets", "the", "content", "-", "length", "header", "to", "the", "response", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/HttpServerHandler.java#L641-L649
17,009
line/armeria
grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java
ArmeriaMessageDeframer.deframe
public void deframe(HttpData data, boolean endOfStream) { requireNonNull(data, "data"); checkNotClosed(); checkState(!this.endOfStream, "Past end of stream"); startedDeframing = true; final int dataLength = data.length(); if (dataLength != 0) { final ByteBuf buf; if (data instanceof ByteBufHolder) { buf = ((ByteBufHolder) data).content(); } else { buf = Unpooled.wrappedBuffer(data.array(), data.offset(), dataLength); } assert unprocessed != null; unprocessed.add(buf); unprocessedBytes += dataLength; } // Indicate that all of the data for this stream has been received. this.endOfStream = endOfStream; deliver(); }
java
public void deframe(HttpData data, boolean endOfStream) { requireNonNull(data, "data"); checkNotClosed(); checkState(!this.endOfStream, "Past end of stream"); startedDeframing = true; final int dataLength = data.length(); if (dataLength != 0) { final ByteBuf buf; if (data instanceof ByteBufHolder) { buf = ((ByteBufHolder) data).content(); } else { buf = Unpooled.wrappedBuffer(data.array(), data.offset(), dataLength); } assert unprocessed != null; unprocessed.add(buf); unprocessedBytes += dataLength; } // Indicate that all of the data for this stream has been received. this.endOfStream = endOfStream; deliver(); }
[ "public", "void", "deframe", "(", "HttpData", "data", ",", "boolean", "endOfStream", ")", "{", "requireNonNull", "(", "data", ",", "\"data\"", ")", ";", "checkNotClosed", "(", ")", ";", "checkState", "(", "!", "this", ".", "endOfStream", ",", "\"Past end of stream\"", ")", ";", "startedDeframing", "=", "true", ";", "final", "int", "dataLength", "=", "data", ".", "length", "(", ")", ";", "if", "(", "dataLength", "!=", "0", ")", "{", "final", "ByteBuf", "buf", ";", "if", "(", "data", "instanceof", "ByteBufHolder", ")", "{", "buf", "=", "(", "(", "ByteBufHolder", ")", "data", ")", ".", "content", "(", ")", ";", "}", "else", "{", "buf", "=", "Unpooled", ".", "wrappedBuffer", "(", "data", ".", "array", "(", ")", ",", "data", ".", "offset", "(", ")", ",", "dataLength", ")", ";", "}", "assert", "unprocessed", "!=", "null", ";", "unprocessed", ".", "add", "(", "buf", ")", ";", "unprocessedBytes", "+=", "dataLength", ";", "}", "// Indicate that all of the data for this stream has been received.", "this", ".", "endOfStream", "=", "endOfStream", ";", "deliver", "(", ")", ";", "}" ]
Adds the given data to this deframer and attempts delivery to the listener. @param data the raw data read from the remote endpoint. Must be non-null. @param endOfStream if {@code true}, indicates that {@code data} is the end of the stream from the remote endpoint. End of stream should not be used in the event of a transport error, such as a stream reset. @throws IllegalStateException if {@link #close()} has been called previously or if this method has previously been called with {@code endOfStream=true}.
[ "Adds", "the", "given", "data", "to", "this", "deframer", "and", "attempts", "delivery", "to", "the", "listener", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java#L235-L258
17,010
line/armeria
grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java
ArmeriaMessageDeframer.close
@Override public void close() { if (unprocessed != null) { try { unprocessed.forEach(ByteBuf::release); } finally { unprocessed = null; } if (endOfStream) { listener.endOfStream(); } } }
java
@Override public void close() { if (unprocessed != null) { try { unprocessed.forEach(ByteBuf::release); } finally { unprocessed = null; } if (endOfStream) { listener.endOfStream(); } } }
[ "@", "Override", "public", "void", "close", "(", ")", "{", "if", "(", "unprocessed", "!=", "null", ")", "{", "try", "{", "unprocessed", ".", "forEach", "(", "ByteBuf", "::", "release", ")", ";", "}", "finally", "{", "unprocessed", "=", "null", ";", "}", "if", "(", "endOfStream", ")", "{", "listener", ".", "endOfStream", "(", ")", ";", "}", "}", "}" ]
Closes this deframer and frees any resources. After this method is called, additional calls will have no effect.
[ "Closes", "this", "deframer", "and", "frees", "any", "resources", ".", "After", "this", "method", "is", "called", "additional", "calls", "will", "have", "no", "effect", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java#L275-L288
17,011
line/armeria
grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java
ArmeriaMessageDeframer.readHeader
private void readHeader() { final int type = readUnsignedByte(); if ((type & RESERVED_MASK) != 0) { throw new ArmeriaStatusException( StatusCodes.INTERNAL, DEBUG_STRING + ": Frame header malformed: reserved bits not zero"); } compressedFlag = (type & COMPRESSED_FLAG_MASK) != 0; // Update the required length to include the length of the frame. requiredLength = readInt(); if (requiredLength < 0 || requiredLength > maxMessageSizeBytes) { throw new ArmeriaStatusException( StatusCodes.RESOURCE_EXHAUSTED, String.format("%s: Frame size %d exceeds maximum: %d. ", DEBUG_STRING, requiredLength, maxMessageSizeBytes)); } // Continue reading the frame body. state = State.BODY; }
java
private void readHeader() { final int type = readUnsignedByte(); if ((type & RESERVED_MASK) != 0) { throw new ArmeriaStatusException( StatusCodes.INTERNAL, DEBUG_STRING + ": Frame header malformed: reserved bits not zero"); } compressedFlag = (type & COMPRESSED_FLAG_MASK) != 0; // Update the required length to include the length of the frame. requiredLength = readInt(); if (requiredLength < 0 || requiredLength > maxMessageSizeBytes) { throw new ArmeriaStatusException( StatusCodes.RESOURCE_EXHAUSTED, String.format("%s: Frame size %d exceeds maximum: %d. ", DEBUG_STRING, requiredLength, maxMessageSizeBytes)); } // Continue reading the frame body. state = State.BODY; }
[ "private", "void", "readHeader", "(", ")", "{", "final", "int", "type", "=", "readUnsignedByte", "(", ")", ";", "if", "(", "(", "type", "&", "RESERVED_MASK", ")", "!=", "0", ")", "{", "throw", "new", "ArmeriaStatusException", "(", "StatusCodes", ".", "INTERNAL", ",", "DEBUG_STRING", "+", "\": Frame header malformed: reserved bits not zero\"", ")", ";", "}", "compressedFlag", "=", "(", "type", "&", "COMPRESSED_FLAG_MASK", ")", "!=", "0", ";", "// Update the required length to include the length of the frame.", "requiredLength", "=", "readInt", "(", ")", ";", "if", "(", "requiredLength", "<", "0", "||", "requiredLength", ">", "maxMessageSizeBytes", ")", "{", "throw", "new", "ArmeriaStatusException", "(", "StatusCodes", ".", "RESOURCE_EXHAUSTED", ",", "String", ".", "format", "(", "\"%s: Frame size %d exceeds maximum: %d. \"", ",", "DEBUG_STRING", ",", "requiredLength", ",", "maxMessageSizeBytes", ")", ")", ";", "}", "// Continue reading the frame body.", "state", "=", "State", ".", "BODY", ";", "}" ]
Processes the gRPC compression header which is composed of the compression flag and the outer frame length.
[ "Processes", "the", "gRPC", "compression", "header", "which", "is", "composed", "of", "the", "compression", "flag", "and", "the", "outer", "frame", "length", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java#L367-L388
17,012
line/armeria
grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java
ArmeriaMessageDeframer.readBody
private void readBody() { final ByteBuf buf = readBytes(requiredLength); final ByteBufOrStream msg = compressedFlag ? getCompressedBody(buf) : getUncompressedBody(buf); listener.messageRead(msg); // Done with this frame, begin processing the next header. state = State.HEADER; requiredLength = HEADER_LENGTH; }
java
private void readBody() { final ByteBuf buf = readBytes(requiredLength); final ByteBufOrStream msg = compressedFlag ? getCompressedBody(buf) : getUncompressedBody(buf); listener.messageRead(msg); // Done with this frame, begin processing the next header. state = State.HEADER; requiredLength = HEADER_LENGTH; }
[ "private", "void", "readBody", "(", ")", "{", "final", "ByteBuf", "buf", "=", "readBytes", "(", "requiredLength", ")", ";", "final", "ByteBufOrStream", "msg", "=", "compressedFlag", "?", "getCompressedBody", "(", "buf", ")", ":", "getUncompressedBody", "(", "buf", ")", ";", "listener", ".", "messageRead", "(", "msg", ")", ";", "// Done with this frame, begin processing the next header.", "state", "=", "State", ".", "HEADER", ";", "requiredLength", "=", "HEADER_LENGTH", ";", "}" ]
Processes the body of the gRPC compression frame. A single compression frame may contain several gRPC messages within it.
[ "Processes", "the", "body", "of", "the", "gRPC", "compression", "frame", ".", "A", "single", "compression", "frame", "may", "contain", "several", "gRPC", "messages", "within", "it", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/grpc-protocol/src/main/java/com/linecorp/armeria/common/grpc/protocol/ArmeriaMessageDeframer.java#L440-L448
17,013
line/armeria
examples/spring-boot-minimal/src/main/java/example/springframework/boot/minimal/HelloAnnotatedService.java
HelloAnnotatedService.hello
@Get("/hello/{name}") public String hello( @Size(min = 3, max = 10, message = "name should have between 3 and 10 characters") @Param String name) { return String.format("Hello, %s! This message is from Armeria annotated service!", name); }
java
@Get("/hello/{name}") public String hello( @Size(min = 3, max = 10, message = "name should have between 3 and 10 characters") @Param String name) { return String.format("Hello, %s! This message is from Armeria annotated service!", name); }
[ "@", "Get", "(", "\"/hello/{name}\"", ")", "public", "String", "hello", "(", "@", "Size", "(", "min", "=", "3", ",", "max", "=", "10", ",", "message", "=", "\"name should have between 3 and 10 characters\"", ")", "@", "Param", "String", "name", ")", "{", "return", "String", ".", "format", "(", "\"Hello, %s! This message is from Armeria annotated service!\"", ",", "name", ")", ";", "}" ]
An example in order to show how to use validation framework in an annotated HTTP service.
[ "An", "example", "in", "order", "to", "show", "how", "to", "use", "validation", "framework", "in", "an", "annotated", "HTTP", "service", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/examples/spring-boot-minimal/src/main/java/example/springframework/boot/minimal/HelloAnnotatedService.java#L31-L36
17,014
line/armeria
retrofit2/src/main/java/com/linecorp/armeria/client/retrofit2/ArmeriaRetrofitBuilder.java
ArmeriaRetrofitBuilder.baseUrl
public ArmeriaRetrofitBuilder baseUrl(String baseUrl) { requireNonNull(baseUrl, "baseUrl"); final URI uri = URI.create(baseUrl); checkArgument(SessionProtocol.find(uri.getScheme()).isPresent(), "baseUrl must have an HTTP scheme: %s", baseUrl); final String path = uri.getPath(); if (!path.isEmpty() && !SLASH.equals(path.substring(path.length() - 1))) { throw new IllegalArgumentException("baseUrl must end with /: " + baseUrl); } this.baseUrl = baseUrl; return this; }
java
public ArmeriaRetrofitBuilder baseUrl(String baseUrl) { requireNonNull(baseUrl, "baseUrl"); final URI uri = URI.create(baseUrl); checkArgument(SessionProtocol.find(uri.getScheme()).isPresent(), "baseUrl must have an HTTP scheme: %s", baseUrl); final String path = uri.getPath(); if (!path.isEmpty() && !SLASH.equals(path.substring(path.length() - 1))) { throw new IllegalArgumentException("baseUrl must end with /: " + baseUrl); } this.baseUrl = baseUrl; return this; }
[ "public", "ArmeriaRetrofitBuilder", "baseUrl", "(", "String", "baseUrl", ")", "{", "requireNonNull", "(", "baseUrl", ",", "\"baseUrl\"", ")", ";", "final", "URI", "uri", "=", "URI", ".", "create", "(", "baseUrl", ")", ";", "checkArgument", "(", "SessionProtocol", ".", "find", "(", "uri", ".", "getScheme", "(", ")", ")", ".", "isPresent", "(", ")", ",", "\"baseUrl must have an HTTP scheme: %s\"", ",", "baseUrl", ")", ";", "final", "String", "path", "=", "uri", ".", "getPath", "(", ")", ";", "if", "(", "!", "path", ".", "isEmpty", "(", ")", "&&", "!", "SLASH", ".", "equals", "(", "path", ".", "substring", "(", "path", ".", "length", "(", ")", "-", "1", ")", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"baseUrl must end with /: \"", "+", "baseUrl", ")", ";", "}", "this", ".", "baseUrl", "=", "baseUrl", ";", "return", "this", ";", "}" ]
Sets the API base URL. @see Builder#baseUrl(String)
[ "Sets", "the", "API", "base", "URL", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/retrofit2/src/main/java/com/linecorp/armeria/client/retrofit2/ArmeriaRetrofitBuilder.java#L107-L118
17,015
line/armeria
core/src/main/java/com/linecorp/armeria/common/stream/EmptyFixedStreamMessage.java
EmptyFixedStreamMessage.doRequest
@Override final void doRequest(SubscriptionImpl subscription, long unused) { if (requested() != 0) { // Already have demand so don't need to do anything. return; } setRequested(1); notifySubscriberOfCloseEvent(subscription, SUCCESSFUL_CLOSE); }
java
@Override final void doRequest(SubscriptionImpl subscription, long unused) { if (requested() != 0) { // Already have demand so don't need to do anything. return; } setRequested(1); notifySubscriberOfCloseEvent(subscription, SUCCESSFUL_CLOSE); }
[ "@", "Override", "final", "void", "doRequest", "(", "SubscriptionImpl", "subscription", ",", "long", "unused", ")", "{", "if", "(", "requested", "(", ")", "!=", "0", ")", "{", "// Already have demand so don't need to do anything.", "return", ";", "}", "setRequested", "(", "1", ")", ";", "notifySubscriberOfCloseEvent", "(", "subscription", ",", "SUCCESSFUL_CLOSE", ")", ";", "}" ]
No objects, so just notify of close as soon as there is demand.
[ "No", "objects", "so", "just", "notify", "of", "close", "as", "soon", "as", "there", "is", "demand", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/common/stream/EmptyFixedStreamMessage.java#L25-L33
17,016
line/armeria
core/src/main/java/com/linecorp/armeria/server/ServerBuilder.java
ServerBuilder.idleTimeout
public ServerBuilder idleTimeout(Duration idleTimeout) { requireNonNull(idleTimeout, "idleTimeout"); idleTimeoutMillis = ServerConfig.validateIdleTimeoutMillis(idleTimeout.toMillis()); return this; }
java
public ServerBuilder idleTimeout(Duration idleTimeout) { requireNonNull(idleTimeout, "idleTimeout"); idleTimeoutMillis = ServerConfig.validateIdleTimeoutMillis(idleTimeout.toMillis()); return this; }
[ "public", "ServerBuilder", "idleTimeout", "(", "Duration", "idleTimeout", ")", "{", "requireNonNull", "(", "idleTimeout", ",", "\"idleTimeout\"", ")", ";", "idleTimeoutMillis", "=", "ServerConfig", ".", "validateIdleTimeoutMillis", "(", "idleTimeout", ".", "toMillis", "(", ")", ")", ";", "return", "this", ";", "}" ]
Sets the idle timeout of a connection for keep-alive. @param idleTimeout the timeout. {@code 0} disables the timeout.
[ "Sets", "the", "idle", "timeout", "of", "a", "connection", "for", "keep", "-", "alive", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/ServerBuilder.java#L462-L466
17,017
line/armeria
core/src/main/java/com/linecorp/armeria/internal/ArmeriaHttpUtil.java
ArmeriaHttpUtil.decodePath
public static String decodePath(String path) { if (path.indexOf('%') < 0) { // No need to decoded; not percent-encoded return path; } // Decode percent-encoded characters. // An invalid character is replaced with 0xFF, which will be replaced into '�' by UTF-8 decoder. final int len = path.length(); final byte[] buf = new byte[len]; int dstLen = 0; for (int i = 0; i < len; i++) { final char ch = path.charAt(i); if (ch != '%') { buf[dstLen++] = (byte) ((ch & 0xFF80) == 0 ? ch : 0xFF); continue; } // Decode a percent-encoded character. final int hexEnd = i + 3; if (hexEnd > len) { // '%' or '%x' (must be followed by two hexadigits) buf[dstLen++] = (byte) 0xFF; break; } final int digit1 = decodeHexNibble(path.charAt(++i)); final int digit2 = decodeHexNibble(path.charAt(++i)); if (digit1 < 0 || digit2 < 0) { // The first or second digit is not hexadecimal. buf[dstLen++] = (byte) 0xFF; } else { buf[dstLen++] = (byte) ((digit1 << 4) | digit2); } } return new String(buf, 0, dstLen, StandardCharsets.UTF_8); }
java
public static String decodePath(String path) { if (path.indexOf('%') < 0) { // No need to decoded; not percent-encoded return path; } // Decode percent-encoded characters. // An invalid character is replaced with 0xFF, which will be replaced into '�' by UTF-8 decoder. final int len = path.length(); final byte[] buf = new byte[len]; int dstLen = 0; for (int i = 0; i < len; i++) { final char ch = path.charAt(i); if (ch != '%') { buf[dstLen++] = (byte) ((ch & 0xFF80) == 0 ? ch : 0xFF); continue; } // Decode a percent-encoded character. final int hexEnd = i + 3; if (hexEnd > len) { // '%' or '%x' (must be followed by two hexadigits) buf[dstLen++] = (byte) 0xFF; break; } final int digit1 = decodeHexNibble(path.charAt(++i)); final int digit2 = decodeHexNibble(path.charAt(++i)); if (digit1 < 0 || digit2 < 0) { // The first or second digit is not hexadecimal. buf[dstLen++] = (byte) 0xFF; } else { buf[dstLen++] = (byte) ((digit1 << 4) | digit2); } } return new String(buf, 0, dstLen, StandardCharsets.UTF_8); }
[ "public", "static", "String", "decodePath", "(", "String", "path", ")", "{", "if", "(", "path", ".", "indexOf", "(", "'", "'", ")", "<", "0", ")", "{", "// No need to decoded; not percent-encoded", "return", "path", ";", "}", "// Decode percent-encoded characters.", "// An invalid character is replaced with 0xFF, which will be replaced into '�' by UTF-8 decoder.", "final", "int", "len", "=", "path", ".", "length", "(", ")", ";", "final", "byte", "[", "]", "buf", "=", "new", "byte", "[", "len", "]", ";", "int", "dstLen", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "final", "char", "ch", "=", "path", ".", "charAt", "(", "i", ")", ";", "if", "(", "ch", "!=", "'", "'", ")", "{", "buf", "[", "dstLen", "++", "]", "=", "(", "byte", ")", "(", "(", "ch", "&", "0xFF80", ")", "==", "0", "?", "ch", ":", "0xFF", ")", ";", "continue", ";", "}", "// Decode a percent-encoded character.", "final", "int", "hexEnd", "=", "i", "+", "3", ";", "if", "(", "hexEnd", ">", "len", ")", "{", "// '%' or '%x' (must be followed by two hexadigits)", "buf", "[", "dstLen", "++", "]", "=", "(", "byte", ")", "0xFF", ";", "break", ";", "}", "final", "int", "digit1", "=", "decodeHexNibble", "(", "path", ".", "charAt", "(", "++", "i", ")", ")", ";", "final", "int", "digit2", "=", "decodeHexNibble", "(", "path", ".", "charAt", "(", "++", "i", ")", ")", ";", "if", "(", "digit1", "<", "0", "||", "digit2", "<", "0", ")", "{", "// The first or second digit is not hexadecimal.", "buf", "[", "dstLen", "++", "]", "=", "(", "byte", ")", "0xFF", ";", "}", "else", "{", "buf", "[", "dstLen", "++", "]", "=", "(", "byte", ")", "(", "(", "digit1", "<<", "4", ")", "|", "digit2", ")", ";", "}", "}", "return", "new", "String", "(", "buf", ",", "0", ",", "dstLen", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "}" ]
Decodes a percent-encoded path string.
[ "Decodes", "a", "percent", "-", "encoded", "path", "string", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/internal/ArmeriaHttpUtil.java#L294-L331
17,018
line/armeria
tomcat/src/main/java/com/linecorp/armeria/server/tomcat/Tomcat90InputBuffer.java
Tomcat90InputBuffer.doRead
public int doRead(ByteChunk chunk) { if (!isNeedToRead()) { // Read only once. return -1; } read = true; final int readableBytes = content.length(); chunk.setBytes(content.array(), content.offset(), readableBytes); return readableBytes; }
java
public int doRead(ByteChunk chunk) { if (!isNeedToRead()) { // Read only once. return -1; } read = true; final int readableBytes = content.length(); chunk.setBytes(content.array(), content.offset(), readableBytes); return readableBytes; }
[ "public", "int", "doRead", "(", "ByteChunk", "chunk", ")", "{", "if", "(", "!", "isNeedToRead", "(", ")", ")", "{", "// Read only once.", "return", "-", "1", ";", "}", "read", "=", "true", ";", "final", "int", "readableBytes", "=", "content", ".", "length", "(", ")", ";", "chunk", ".", "setBytes", "(", "content", ".", "array", "(", ")", ",", "content", ".", "offset", "(", ")", ",", "readableBytes", ")", ";", "return", "readableBytes", ";", "}" ]
Required for 8.5.
[ "Required", "for", "8", ".", "5", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/tomcat/src/main/java/com/linecorp/armeria/server/tomcat/Tomcat90InputBuffer.java#L36-L48
17,019
line/armeria
core/src/main/java/com/linecorp/armeria/client/endpoint/healthcheck/HealthCheckedEndpointGroup.java
HealthCheckedEndpointGroup.updateServerList
private List<ServerConnection> updateServerList() { final Map<Endpoint, ServerConnection> allServersByEndpoint = allServers .stream() .collect(toImmutableMap(ServerConnection::endpoint, Function.identity(), (l, r) -> l)); return allServers = delegate .endpoints() .stream() .map(endpoint -> { ServerConnection connection = allServersByEndpoint.get(endpoint); if (connection != null) { return connection; } return new ServerConnection(endpoint, createEndpointHealthChecker(endpoint)); }) .collect(toImmutableList()); }
java
private List<ServerConnection> updateServerList() { final Map<Endpoint, ServerConnection> allServersByEndpoint = allServers .stream() .collect(toImmutableMap(ServerConnection::endpoint, Function.identity(), (l, r) -> l)); return allServers = delegate .endpoints() .stream() .map(endpoint -> { ServerConnection connection = allServersByEndpoint.get(endpoint); if (connection != null) { return connection; } return new ServerConnection(endpoint, createEndpointHealthChecker(endpoint)); }) .collect(toImmutableList()); }
[ "private", "List", "<", "ServerConnection", ">", "updateServerList", "(", ")", "{", "final", "Map", "<", "Endpoint", ",", "ServerConnection", ">", "allServersByEndpoint", "=", "allServers", ".", "stream", "(", ")", ".", "collect", "(", "toImmutableMap", "(", "ServerConnection", "::", "endpoint", ",", "Function", ".", "identity", "(", ")", ",", "(", "l", ",", "r", ")", "->", "l", ")", ")", ";", "return", "allServers", "=", "delegate", ".", "endpoints", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "endpoint", "->", "{", "ServerConnection", "connection", "=", "allServersByEndpoint", ".", "get", "(", "endpoint", ")", ";", "if", "(", "connection", "!=", "null", ")", "{", "return", "connection", ";", "}", "return", "new", "ServerConnection", "(", "endpoint", ",", "createEndpointHealthChecker", "(", "endpoint", ")", ")", ";", "}", ")", ".", "collect", "(", "toImmutableList", "(", ")", ")", ";", "}" ]
Update the servers this health checker client talks to.
[ "Update", "the", "servers", "this", "health", "checker", "client", "talks", "to", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/client/endpoint/healthcheck/HealthCheckedEndpointGroup.java#L109-L126
17,020
line/armeria
core/src/main/java/com/linecorp/armeria/server/cors/CorsService.java
CorsService.handleCorsPreflight
private HttpResponse handleCorsPreflight(ServiceRequestContext ctx, HttpRequest req) { final HttpHeaders headers = HttpHeaders.of(HttpStatus.OK); final CorsPolicy policy = setCorsOrigin(ctx, req, headers); if (policy != null) { policy.setCorsAllowMethods(headers); policy.setCorsAllowHeaders(headers); policy.setCorsAllowCredentials(headers); policy.setCorsMaxAge(headers); policy.setCorsPreflightResponseHeaders(headers); } return HttpResponse.of(headers); }
java
private HttpResponse handleCorsPreflight(ServiceRequestContext ctx, HttpRequest req) { final HttpHeaders headers = HttpHeaders.of(HttpStatus.OK); final CorsPolicy policy = setCorsOrigin(ctx, req, headers); if (policy != null) { policy.setCorsAllowMethods(headers); policy.setCorsAllowHeaders(headers); policy.setCorsAllowCredentials(headers); policy.setCorsMaxAge(headers); policy.setCorsPreflightResponseHeaders(headers); } return HttpResponse.of(headers); }
[ "private", "HttpResponse", "handleCorsPreflight", "(", "ServiceRequestContext", "ctx", ",", "HttpRequest", "req", ")", "{", "final", "HttpHeaders", "headers", "=", "HttpHeaders", ".", "of", "(", "HttpStatus", ".", "OK", ")", ";", "final", "CorsPolicy", "policy", "=", "setCorsOrigin", "(", "ctx", ",", "req", ",", "headers", ")", ";", "if", "(", "policy", "!=", "null", ")", "{", "policy", ".", "setCorsAllowMethods", "(", "headers", ")", ";", "policy", ".", "setCorsAllowHeaders", "(", "headers", ")", ";", "policy", ".", "setCorsAllowCredentials", "(", "headers", ")", ";", "policy", ".", "setCorsMaxAge", "(", "headers", ")", ";", "policy", ".", "setCorsPreflightResponseHeaders", "(", "headers", ")", ";", "}", "return", "HttpResponse", ".", "of", "(", "headers", ")", ";", "}" ]
Handles CORS preflight by setting the appropriate headers. @param req the decoded HTTP request
[ "Handles", "CORS", "preflight", "by", "setting", "the", "appropriate", "headers", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/cors/CorsService.java#L109-L121
17,021
line/armeria
core/src/main/java/com/linecorp/armeria/server/cors/CorsService.java
CorsService.setCorsResponseHeaders
private void setCorsResponseHeaders(ServiceRequestContext ctx, HttpRequest req, HttpHeaders headers) { final CorsPolicy policy = setCorsOrigin(ctx, req, headers); if (policy != null) { policy.setCorsAllowCredentials(headers); policy.setCorsAllowHeaders(headers); policy.setCorsExposeHeaders(headers); } }
java
private void setCorsResponseHeaders(ServiceRequestContext ctx, HttpRequest req, HttpHeaders headers) { final CorsPolicy policy = setCorsOrigin(ctx, req, headers); if (policy != null) { policy.setCorsAllowCredentials(headers); policy.setCorsAllowHeaders(headers); policy.setCorsExposeHeaders(headers); } }
[ "private", "void", "setCorsResponseHeaders", "(", "ServiceRequestContext", "ctx", ",", "HttpRequest", "req", ",", "HttpHeaders", "headers", ")", "{", "final", "CorsPolicy", "policy", "=", "setCorsOrigin", "(", "ctx", ",", "req", ",", "headers", ")", ";", "if", "(", "policy", "!=", "null", ")", "{", "policy", ".", "setCorsAllowCredentials", "(", "headers", ")", ";", "policy", ".", "setCorsAllowHeaders", "(", "headers", ")", ";", "policy", ".", "setCorsExposeHeaders", "(", "headers", ")", ";", "}", "}" ]
Emit CORS headers if origin was found. @param req the HTTP request with the CORS info @param headers the headers to modify
[ "Emit", "CORS", "headers", "if", "origin", "was", "found", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/cors/CorsService.java#L129-L137
17,022
line/armeria
core/src/main/java/com/linecorp/armeria/server/cors/CorsService.java
CorsService.setCorsOrigin
@Nullable private CorsPolicy setCorsOrigin(ServiceRequestContext ctx, HttpRequest request, HttpHeaders headers) { if (!config.isEnabled()) { return null; } final String origin = request.headers().get(HttpHeaderNames.ORIGIN); if (origin != null) { final CorsPolicy policy = config.getPolicy(origin, ctx.pathMappingContext()); if (policy == null) { logger.debug( "{} There is no CORS policy configured for the request origin '{}' and the path '{}'.", ctx, origin, ctx.path()); return null; } if (NULL_ORIGIN.equals(origin)) { setCorsNullOrigin(headers); return policy; } if (config.isAnyOriginSupported()) { if (policy.isCredentialsAllowed()) { echoCorsRequestOrigin(request, headers); setCorsVaryHeader(headers); } else { setCorsAnyOrigin(headers); } return policy; } setCorsOrigin(headers, origin); setCorsVaryHeader(headers); return policy; } return null; }
java
@Nullable private CorsPolicy setCorsOrigin(ServiceRequestContext ctx, HttpRequest request, HttpHeaders headers) { if (!config.isEnabled()) { return null; } final String origin = request.headers().get(HttpHeaderNames.ORIGIN); if (origin != null) { final CorsPolicy policy = config.getPolicy(origin, ctx.pathMappingContext()); if (policy == null) { logger.debug( "{} There is no CORS policy configured for the request origin '{}' and the path '{}'.", ctx, origin, ctx.path()); return null; } if (NULL_ORIGIN.equals(origin)) { setCorsNullOrigin(headers); return policy; } if (config.isAnyOriginSupported()) { if (policy.isCredentialsAllowed()) { echoCorsRequestOrigin(request, headers); setCorsVaryHeader(headers); } else { setCorsAnyOrigin(headers); } return policy; } setCorsOrigin(headers, origin); setCorsVaryHeader(headers); return policy; } return null; }
[ "@", "Nullable", "private", "CorsPolicy", "setCorsOrigin", "(", "ServiceRequestContext", "ctx", ",", "HttpRequest", "request", ",", "HttpHeaders", "headers", ")", "{", "if", "(", "!", "config", ".", "isEnabled", "(", ")", ")", "{", "return", "null", ";", "}", "final", "String", "origin", "=", "request", ".", "headers", "(", ")", ".", "get", "(", "HttpHeaderNames", ".", "ORIGIN", ")", ";", "if", "(", "origin", "!=", "null", ")", "{", "final", "CorsPolicy", "policy", "=", "config", ".", "getPolicy", "(", "origin", ",", "ctx", ".", "pathMappingContext", "(", ")", ")", ";", "if", "(", "policy", "==", "null", ")", "{", "logger", ".", "debug", "(", "\"{} There is no CORS policy configured for the request origin '{}' and the path '{}'.\"", ",", "ctx", ",", "origin", ",", "ctx", ".", "path", "(", ")", ")", ";", "return", "null", ";", "}", "if", "(", "NULL_ORIGIN", ".", "equals", "(", "origin", ")", ")", "{", "setCorsNullOrigin", "(", "headers", ")", ";", "return", "policy", ";", "}", "if", "(", "config", ".", "isAnyOriginSupported", "(", ")", ")", "{", "if", "(", "policy", ".", "isCredentialsAllowed", "(", ")", ")", "{", "echoCorsRequestOrigin", "(", "request", ",", "headers", ")", ";", "setCorsVaryHeader", "(", "headers", ")", ";", "}", "else", "{", "setCorsAnyOrigin", "(", "headers", ")", ";", "}", "return", "policy", ";", "}", "setCorsOrigin", "(", "headers", ",", "origin", ")", ";", "setCorsVaryHeader", "(", "headers", ")", ";", "return", "policy", ";", "}", "return", "null", ";", "}" ]
Sets origin header according to the given CORS configuration and HTTP request. @param request the HTTP request @param headers the HTTP headers to modify @return {@code policy} if CORS configuration matches, otherwise {@code null}
[ "Sets", "origin", "header", "according", "to", "the", "given", "CORS", "configuration", "and", "HTTP", "request", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/cors/CorsService.java#L154-L187
17,023
line/armeria
core/src/main/java/com/linecorp/armeria/server/PathMappingResultBuilder.java
PathMappingResultBuilder.decodedParam
public PathMappingResultBuilder decodedParam(String name, String value) { params.put(requireNonNull(name, "name"), requireNonNull(value, "value")); return this; }
java
public PathMappingResultBuilder decodedParam(String name, String value) { params.put(requireNonNull(name, "name"), requireNonNull(value, "value")); return this; }
[ "public", "PathMappingResultBuilder", "decodedParam", "(", "String", "name", ",", "String", "value", ")", "{", "params", ".", "put", "(", "requireNonNull", "(", "name", ",", "\"name\"", ")", ",", "requireNonNull", "(", "value", ",", "\"value\"", ")", ")", ";", "return", "this", ";", "}" ]
Adds a decoded path parameter.
[ "Adds", "a", "decoded", "path", "parameter", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/PathMappingResultBuilder.java#L69-L72
17,024
line/armeria
core/src/main/java/com/linecorp/armeria/server/PathMappingResultBuilder.java
PathMappingResultBuilder.rawParam
public PathMappingResultBuilder rawParam(String name, String value) { params.put(requireNonNull(name, "name"), ArmeriaHttpUtil.decodePath(requireNonNull(value, "value"))); return this; }
java
public PathMappingResultBuilder rawParam(String name, String value) { params.put(requireNonNull(name, "name"), ArmeriaHttpUtil.decodePath(requireNonNull(value, "value"))); return this; }
[ "public", "PathMappingResultBuilder", "rawParam", "(", "String", "name", ",", "String", "value", ")", "{", "params", ".", "put", "(", "requireNonNull", "(", "name", ",", "\"name\"", ")", ",", "ArmeriaHttpUtil", ".", "decodePath", "(", "requireNonNull", "(", "value", ",", "\"value\"", ")", ")", ")", ";", "return", "this", ";", "}" ]
Adds an encoded path parameter, which will be decoded in UTF-8 automatically.
[ "Adds", "an", "encoded", "path", "parameter", "which", "will", "be", "decoded", "in", "UTF", "-", "8", "automatically", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/PathMappingResultBuilder.java#L77-L80
17,025
line/armeria
core/src/main/java/com/linecorp/armeria/server/VirtualHost.java
VirtualHost.ensureHostnamePatternMatchesDefaultHostname
static void ensureHostnamePatternMatchesDefaultHostname(String hostnamePattern, String defaultHostname) { if ("*".equals(hostnamePattern)) { return; } // Pretty convoluted way to validate but it's done only once and // we don't need to duplicate the pattern matching logic. final DomainNameMapping<Boolean> mapping = new DomainNameMappingBuilder<>(Boolean.FALSE).add(hostnamePattern, Boolean.TRUE).build(); if (!mapping.map(defaultHostname)) { throw new IllegalArgumentException( "defaultHostname: " + defaultHostname + " (must be matched by hostnamePattern: " + hostnamePattern + ')'); } }
java
static void ensureHostnamePatternMatchesDefaultHostname(String hostnamePattern, String defaultHostname) { if ("*".equals(hostnamePattern)) { return; } // Pretty convoluted way to validate but it's done only once and // we don't need to duplicate the pattern matching logic. final DomainNameMapping<Boolean> mapping = new DomainNameMappingBuilder<>(Boolean.FALSE).add(hostnamePattern, Boolean.TRUE).build(); if (!mapping.map(defaultHostname)) { throw new IllegalArgumentException( "defaultHostname: " + defaultHostname + " (must be matched by hostnamePattern: " + hostnamePattern + ')'); } }
[ "static", "void", "ensureHostnamePatternMatchesDefaultHostname", "(", "String", "hostnamePattern", ",", "String", "defaultHostname", ")", "{", "if", "(", "\"*\"", ".", "equals", "(", "hostnamePattern", ")", ")", "{", "return", ";", "}", "// Pretty convoluted way to validate but it's done only once and", "// we don't need to duplicate the pattern matching logic.", "final", "DomainNameMapping", "<", "Boolean", ">", "mapping", "=", "new", "DomainNameMappingBuilder", "<>", "(", "Boolean", ".", "FALSE", ")", ".", "add", "(", "hostnamePattern", ",", "Boolean", ".", "TRUE", ")", ".", "build", "(", ")", ";", "if", "(", "!", "mapping", ".", "map", "(", "defaultHostname", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"defaultHostname: \"", "+", "defaultHostname", "+", "\" (must be matched by hostnamePattern: \"", "+", "hostnamePattern", "+", "'", "'", ")", ";", "}", "}" ]
Ensure that 'hostnamePattern' matches 'defaultHostname'.
[ "Ensure", "that", "hostnamePattern", "matches", "defaultHostname", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/VirtualHost.java#L195-L210
17,026
line/armeria
thrift/src/main/java/com/linecorp/armeria/internal/thrift/ThriftFunction.java
ThriftFunction.newArgs
public TBase<?, ?> newArgs(List<Object> args) { requireNonNull(args, "args"); final TBase<?, ?> newArgs = newArgs(); final int size = args.size(); for (int i = 0; i < size; i++) { ThriftFieldAccess.set(newArgs, argFields[i], args.get(i)); } return newArgs; }
java
public TBase<?, ?> newArgs(List<Object> args) { requireNonNull(args, "args"); final TBase<?, ?> newArgs = newArgs(); final int size = args.size(); for (int i = 0; i < size; i++) { ThriftFieldAccess.set(newArgs, argFields[i], args.get(i)); } return newArgs; }
[ "public", "TBase", "<", "?", ",", "?", ">", "newArgs", "(", "List", "<", "Object", ">", "args", ")", "{", "requireNonNull", "(", "args", ",", "\"args\"", ")", ";", "final", "TBase", "<", "?", ",", "?", ">", "newArgs", "=", "newArgs", "(", ")", ";", "final", "int", "size", "=", "args", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "ThriftFieldAccess", ".", "set", "(", "newArgs", ",", "argFields", "[", "i", "]", ",", "args", ".", "get", "(", "i", ")", ")", ";", "}", "return", "newArgs", ";", "}" ]
Returns a new arguments instance.
[ "Returns", "a", "new", "arguments", "instance", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/thrift/src/main/java/com/linecorp/armeria/internal/thrift/ThriftFunction.java#L211-L219
17,027
line/armeria
thrift/src/main/java/com/linecorp/armeria/common/thrift/text/TTextProtocol.java
TTextProtocol.writeMessageBegin
@Override public void writeMessageBegin(TMessage message) throws TException { try { getCurrentWriter().writeStartObject(); getCurrentWriter().writeFieldName("method"); getCurrentWriter().writeString(message.name); getCurrentWriter().writeFieldName("type"); TypedParser.TMESSAGE_TYPE.writeValue(getCurrentWriter(), message.type); getCurrentWriter().writeFieldName("seqid"); getCurrentWriter().writeNumber(message.seqid); getCurrentWriter().writeFieldName("args"); } catch (IOException e) { throw new TTransportException(e); } }
java
@Override public void writeMessageBegin(TMessage message) throws TException { try { getCurrentWriter().writeStartObject(); getCurrentWriter().writeFieldName("method"); getCurrentWriter().writeString(message.name); getCurrentWriter().writeFieldName("type"); TypedParser.TMESSAGE_TYPE.writeValue(getCurrentWriter(), message.type); getCurrentWriter().writeFieldName("seqid"); getCurrentWriter().writeNumber(message.seqid); getCurrentWriter().writeFieldName("args"); } catch (IOException e) { throw new TTransportException(e); } }
[ "@", "Override", "public", "void", "writeMessageBegin", "(", "TMessage", "message", ")", "throws", "TException", "{", "try", "{", "getCurrentWriter", "(", ")", ".", "writeStartObject", "(", ")", ";", "getCurrentWriter", "(", ")", ".", "writeFieldName", "(", "\"method\"", ")", ";", "getCurrentWriter", "(", ")", ".", "writeString", "(", "message", ".", "name", ")", ";", "getCurrentWriter", "(", ")", ".", "writeFieldName", "(", "\"type\"", ")", ";", "TypedParser", ".", "TMESSAGE_TYPE", ".", "writeValue", "(", "getCurrentWriter", "(", ")", ",", "message", ".", "type", ")", ";", "getCurrentWriter", "(", ")", ".", "writeFieldName", "(", "\"seqid\"", ")", ";", "getCurrentWriter", "(", ")", ".", "writeNumber", "(", "message", ".", "seqid", ")", ";", "getCurrentWriter", "(", ")", ".", "writeFieldName", "(", "\"args\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "TTransportException", "(", "e", ")", ";", "}", "}" ]
I believe these two messages are called for a thrift service interface. We don't plan on storing any text objects of that type on disk.
[ "I", "believe", "these", "two", "messages", "are", "called", "for", "a", "thrift", "service", "interface", ".", "We", "don", "t", "plan", "on", "storing", "any", "text", "objects", "of", "that", "type", "on", "disk", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/thrift/src/main/java/com/linecorp/armeria/common/thrift/text/TTextProtocol.java#L170-L184
17,028
line/armeria
thrift/src/main/java/com/linecorp/armeria/common/thrift/text/TTextProtocol.java
TTextProtocol.readRoot
private void readRoot() throws IOException { if (root != null) { return; } final ByteArrayOutputStream content = new ByteArrayOutputStream(); final byte[] buffer = new byte[READ_BUFFER_SIZE]; try { while (trans_.read(buffer, 0, READ_BUFFER_SIZE) > 0) { content.write(buffer); } } catch (TTransportException e) { if (TTransportException.END_OF_FILE != e.getType()) { throw new IOException(e); } } root = OBJECT_MAPPER.readTree(content.toByteArray()); }
java
private void readRoot() throws IOException { if (root != null) { return; } final ByteArrayOutputStream content = new ByteArrayOutputStream(); final byte[] buffer = new byte[READ_BUFFER_SIZE]; try { while (trans_.read(buffer, 0, READ_BUFFER_SIZE) > 0) { content.write(buffer); } } catch (TTransportException e) { if (TTransportException.END_OF_FILE != e.getType()) { throw new IOException(e); } } root = OBJECT_MAPPER.readTree(content.toByteArray()); }
[ "private", "void", "readRoot", "(", ")", "throws", "IOException", "{", "if", "(", "root", "!=", "null", ")", "{", "return", ";", "}", "final", "ByteArrayOutputStream", "content", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "final", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "READ_BUFFER_SIZE", "]", ";", "try", "{", "while", "(", "trans_", ".", "read", "(", "buffer", ",", "0", ",", "READ_BUFFER_SIZE", ")", ">", "0", ")", "{", "content", ".", "write", "(", "buffer", ")", ";", "}", "}", "catch", "(", "TTransportException", "e", ")", "{", "if", "(", "TTransportException", ".", "END_OF_FILE", "!=", "e", ".", "getType", "(", ")", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "}", "root", "=", "OBJECT_MAPPER", ".", "readTree", "(", "content", ".", "toByteArray", "(", ")", ")", ";", "}" ]
Read in the root node if it has not yet been read.
[ "Read", "in", "the", "root", "node", "if", "it", "has", "not", "yet", "been", "read", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/thrift/src/main/java/com/linecorp/armeria/common/thrift/text/TTextProtocol.java#L659-L675
17,029
line/armeria
saml/src/main/java/com/linecorp/armeria/server/saml/SamlServiceProvider.java
SamlServiceProvider.newSamlDecorator
public Function<Service<HttpRequest, HttpResponse>, Service<HttpRequest, HttpResponse>> newSamlDecorator() { return delegate -> new SamlDecorator(this, delegate); }
java
public Function<Service<HttpRequest, HttpResponse>, Service<HttpRequest, HttpResponse>> newSamlDecorator() { return delegate -> new SamlDecorator(this, delegate); }
[ "public", "Function", "<", "Service", "<", "HttpRequest", ",", "HttpResponse", ">", ",", "Service", "<", "HttpRequest", ",", "HttpResponse", ">", ">", "newSamlDecorator", "(", ")", "{", "return", "delegate", "->", "new", "SamlDecorator", "(", "this", ",", "delegate", ")", ";", "}" ]
Creates a decorator which initiates a SAML authentication if a request is not authenticated.
[ "Creates", "a", "decorator", "which", "initiates", "a", "SAML", "authentication", "if", "a", "request", "is", "not", "authenticated", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/saml/src/main/java/com/linecorp/armeria/server/saml/SamlServiceProvider.java#L245-L248
17,030
line/armeria
zipkin/src/main/java/com/linecorp/armeria/common/tracing/RequestContextCurrentTraceContext.java
RequestContextCurrentTraceContext.copy
public static void copy(RequestContext src, RequestContext dst) { dst.attr(TRACE_CONTEXT_KEY).set(src.attr(TRACE_CONTEXT_KEY).get()); }
java
public static void copy(RequestContext src, RequestContext dst) { dst.attr(TRACE_CONTEXT_KEY).set(src.attr(TRACE_CONTEXT_KEY).get()); }
[ "public", "static", "void", "copy", "(", "RequestContext", "src", ",", "RequestContext", "dst", ")", "{", "dst", ".", "attr", "(", "TRACE_CONTEXT_KEY", ")", ".", "set", "(", "src", ".", "attr", "(", "TRACE_CONTEXT_KEY", ")", ".", "get", "(", ")", ")", ";", "}" ]
Use this to ensure the trace context propagates to children. <p>Ex. <pre>{@code // Ensure the trace context propagates to children ctx.onChild(RequestContextCurrentTraceContext::copy); }</pre>
[ "Use", "this", "to", "ensure", "the", "trace", "context", "propagates", "to", "children", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/zipkin/src/main/java/com/linecorp/armeria/common/tracing/RequestContextCurrentTraceContext.java#L151-L153
17,031
line/armeria
zipkin/src/main/java/com/linecorp/armeria/common/tracing/RequestContextCurrentTraceContext.java
RequestContextCurrentTraceContext.getTraceContextAttributeOrWarnOnce
@Nullable private static Attribute<TraceContext> getTraceContextAttributeOrWarnOnce() { final RequestContext ctx = getRequestContextOrWarnOnce(); if (ctx == null) { return null; } return ctx.attr(TRACE_CONTEXT_KEY); }
java
@Nullable private static Attribute<TraceContext> getTraceContextAttributeOrWarnOnce() { final RequestContext ctx = getRequestContextOrWarnOnce(); if (ctx == null) { return null; } return ctx.attr(TRACE_CONTEXT_KEY); }
[ "@", "Nullable", "private", "static", "Attribute", "<", "TraceContext", ">", "getTraceContextAttributeOrWarnOnce", "(", ")", "{", "final", "RequestContext", "ctx", "=", "getRequestContextOrWarnOnce", "(", ")", ";", "if", "(", "ctx", "==", "null", ")", "{", "return", "null", ";", "}", "return", "ctx", ".", "attr", "(", "TRACE_CONTEXT_KEY", ")", ";", "}" ]
Armeria code should always have a request context available, and this won't work without it.
[ "Armeria", "code", "should", "always", "have", "a", "request", "context", "available", "and", "this", "won", "t", "work", "without", "it", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/zipkin/src/main/java/com/linecorp/armeria/common/tracing/RequestContextCurrentTraceContext.java#L253-L259
17,032
line/armeria
core/src/main/java/com/linecorp/armeria/common/MediaType.java
MediaType.parameters
@SuppressWarnings({ "unchecked", "rawtypes" }) public Map<String, List<String>> parameters() { return (Map<String, List<String>>) (Map) parameters.asMap(); }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public Map<String, List<String>> parameters() { return (Map<String, List<String>>) (Map) parameters.asMap(); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "parameters", "(", ")", "{", "return", "(", "Map", "<", "String", ",", "List", "<", "String", ">", ">", ")", "(", "Map", ")", "parameters", ".", "asMap", "(", ")", ";", "}" ]
Returns a multimap containing the parameters of this media type.
[ "Returns", "a", "multimap", "containing", "the", "parameters", "of", "this", "media", "type", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/common/MediaType.java#L635-L638
17,033
line/armeria
zipkin/src/main/java/com/linecorp/armeria/internal/tracing/SpanTags.java
SpanTags.addTags
public static void addTags(Span span, RequestLog log) { final String host = log.requestHeaders().authority(); assert host != null; span.tag("http.host", host); final StringBuilder uriBuilder = new StringBuilder() .append(log.scheme().uriText()) .append("://") .append(host) .append(log.path()); if (log.query() != null) { uriBuilder.append('?').append(log.query()); } span.tag("http.method", log.method().name()) .tag("http.path", log.path()) .tag("http.url", uriBuilder.toString()) .tag("http.status_code", log.status().codeAsText()); final Throwable responseCause = log.responseCause(); if (responseCause != null) { span.tag("error", responseCause.toString()); } final SocketAddress raddr = log.context().remoteAddress(); if (raddr != null) { span.tag("address.remote", raddr.toString()); } final SocketAddress laddr = log.context().localAddress(); if (laddr != null) { span.tag("address.local", laddr.toString()); } final Object requestContent = log.requestContent(); if (requestContent instanceof RpcRequest) { span.name(((RpcRequest) requestContent).method()); } }
java
public static void addTags(Span span, RequestLog log) { final String host = log.requestHeaders().authority(); assert host != null; span.tag("http.host", host); final StringBuilder uriBuilder = new StringBuilder() .append(log.scheme().uriText()) .append("://") .append(host) .append(log.path()); if (log.query() != null) { uriBuilder.append('?').append(log.query()); } span.tag("http.method", log.method().name()) .tag("http.path", log.path()) .tag("http.url", uriBuilder.toString()) .tag("http.status_code", log.status().codeAsText()); final Throwable responseCause = log.responseCause(); if (responseCause != null) { span.tag("error", responseCause.toString()); } final SocketAddress raddr = log.context().remoteAddress(); if (raddr != null) { span.tag("address.remote", raddr.toString()); } final SocketAddress laddr = log.context().localAddress(); if (laddr != null) { span.tag("address.local", laddr.toString()); } final Object requestContent = log.requestContent(); if (requestContent instanceof RpcRequest) { span.name(((RpcRequest) requestContent).method()); } }
[ "public", "static", "void", "addTags", "(", "Span", "span", ",", "RequestLog", "log", ")", "{", "final", "String", "host", "=", "log", ".", "requestHeaders", "(", ")", ".", "authority", "(", ")", ";", "assert", "host", "!=", "null", ";", "span", ".", "tag", "(", "\"http.host\"", ",", "host", ")", ";", "final", "StringBuilder", "uriBuilder", "=", "new", "StringBuilder", "(", ")", ".", "append", "(", "log", ".", "scheme", "(", ")", ".", "uriText", "(", ")", ")", ".", "append", "(", "\"://\"", ")", ".", "append", "(", "host", ")", ".", "append", "(", "log", ".", "path", "(", ")", ")", ";", "if", "(", "log", ".", "query", "(", ")", "!=", "null", ")", "{", "uriBuilder", ".", "append", "(", "'", "'", ")", ".", "append", "(", "log", ".", "query", "(", ")", ")", ";", "}", "span", ".", "tag", "(", "\"http.method\"", ",", "log", ".", "method", "(", ")", ".", "name", "(", ")", ")", ".", "tag", "(", "\"http.path\"", ",", "log", ".", "path", "(", ")", ")", ".", "tag", "(", "\"http.url\"", ",", "uriBuilder", ".", "toString", "(", ")", ")", ".", "tag", "(", "\"http.status_code\"", ",", "log", ".", "status", "(", ")", ".", "codeAsText", "(", ")", ")", ";", "final", "Throwable", "responseCause", "=", "log", ".", "responseCause", "(", ")", ";", "if", "(", "responseCause", "!=", "null", ")", "{", "span", ".", "tag", "(", "\"error\"", ",", "responseCause", ".", "toString", "(", ")", ")", ";", "}", "final", "SocketAddress", "raddr", "=", "log", ".", "context", "(", ")", ".", "remoteAddress", "(", ")", ";", "if", "(", "raddr", "!=", "null", ")", "{", "span", ".", "tag", "(", "\"address.remote\"", ",", "raddr", ".", "toString", "(", ")", ")", ";", "}", "final", "SocketAddress", "laddr", "=", "log", ".", "context", "(", ")", ".", "localAddress", "(", ")", ";", "if", "(", "laddr", "!=", "null", ")", "{", "span", ".", "tag", "(", "\"address.local\"", ",", "laddr", ".", "toString", "(", ")", ")", ";", "}", "final", "Object", "requestContent", "=", "log", ".", "requestContent", "(", ")", ";", "if", "(", "requestContent", "instanceof", "RpcRequest", ")", "{", "span", ".", "name", "(", "(", "(", "RpcRequest", ")", "requestContent", ")", ".", "method", "(", ")", ")", ";", "}", "}" ]
Adds information about the raw HTTP request, RPC request, and endpoint to the span.
[ "Adds", "information", "about", "the", "raw", "HTTP", "request", "RPC", "request", "and", "endpoint", "to", "the", "span", "." ]
67d29e019fd35a35f89c45cc8f9119ff9b12b44d
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/zipkin/src/main/java/com/linecorp/armeria/internal/tracing/SpanTags.java#L40-L74
17,034
jankotek/mapdb
src/main/java/org/mapdb/io/DataIO.java
DataIO.packLongSize
public static int packLongSize(long value) { int shift = 63-Long.numberOfLeadingZeros(value); shift -= shift%7; // round down to nearest multiple of 7 int ret = 1; while(shift!=0){ //PERF remove cycle, just count zeroes shift-=7; ret++; } return ret; }
java
public static int packLongSize(long value) { int shift = 63-Long.numberOfLeadingZeros(value); shift -= shift%7; // round down to nearest multiple of 7 int ret = 1; while(shift!=0){ //PERF remove cycle, just count zeroes shift-=7; ret++; } return ret; }
[ "public", "static", "int", "packLongSize", "(", "long", "value", ")", "{", "int", "shift", "=", "63", "-", "Long", ".", "numberOfLeadingZeros", "(", "value", ")", ";", "shift", "-=", "shift", "%", "7", ";", "// round down to nearest multiple of 7", "int", "ret", "=", "1", ";", "while", "(", "shift", "!=", "0", ")", "{", "//PERF remove cycle, just count zeroes", "shift", "-=", "7", ";", "ret", "++", ";", "}", "return", "ret", ";", "}" ]
Calculate how much bytes packed long consumes. @param value to calculate @return number of bytes used in packed form
[ "Calculate", "how", "much", "bytes", "packed", "long", "consumes", "." ]
dfd873b2b9cc4e299228839c100adf93a98f1903
https://github.com/jankotek/mapdb/blob/dfd873b2b9cc4e299228839c100adf93a98f1903/src/main/java/org/mapdb/io/DataIO.java#L151-L161
17,035
jankotek/mapdb
src/main/java/org/mapdb/io/DataIO.java
DataIO.unpackRecid
static public long unpackRecid(DataInput2 in) throws IOException { long val = in.readPackedLong(); val = DataIO.parity1Get(val); return val >>> 1; }
java
static public long unpackRecid(DataInput2 in) throws IOException { long val = in.readPackedLong(); val = DataIO.parity1Get(val); return val >>> 1; }
[ "static", "public", "long", "unpackRecid", "(", "DataInput2", "in", ")", "throws", "IOException", "{", "long", "val", "=", "in", ".", "readPackedLong", "(", ")", ";", "val", "=", "DataIO", ".", "parity1Get", "(", "val", ")", ";", "return", "val", ">>>", "1", ";", "}" ]
Unpack RECID value from the input stream with 3 bit checksum. @param in The input stream. @return The long value. @throws java.io.IOException in case of IO error
[ "Unpack", "RECID", "value", "from", "the", "input", "stream", "with", "3", "bit", "checksum", "." ]
dfd873b2b9cc4e299228839c100adf93a98f1903
https://github.com/jankotek/mapdb/blob/dfd873b2b9cc4e299228839c100adf93a98f1903/src/main/java/org/mapdb/io/DataIO.java#L171-L175
17,036
jankotek/mapdb
src/main/java/org/mapdb/io/DataIO.java
DataIO.toHexa
public static String toHexa( byte [] bb ) { char[] HEXA_CHARS = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; char[] ret = new char[bb.length*2]; for(int i=0;i<bb.length;i++){ ret[i*2] =HEXA_CHARS[((bb[i]& 0xF0) >> 4)]; ret[i*2+1] = HEXA_CHARS[((bb[i] & 0x0F))]; } return new String(ret); }
java
public static String toHexa( byte [] bb ) { char[] HEXA_CHARS = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; char[] ret = new char[bb.length*2]; for(int i=0;i<bb.length;i++){ ret[i*2] =HEXA_CHARS[((bb[i]& 0xF0) >> 4)]; ret[i*2+1] = HEXA_CHARS[((bb[i] & 0x0F))]; } return new String(ret); }
[ "public", "static", "String", "toHexa", "(", "byte", "[", "]", "bb", ")", "{", "char", "[", "]", "HEXA_CHARS", "=", "{", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", ",", "'", "'", "}", ";", "char", "[", "]", "ret", "=", "new", "char", "[", "bb", ".", "length", "*", "2", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bb", ".", "length", ";", "i", "++", ")", "{", "ret", "[", "i", "*", "2", "]", "=", "HEXA_CHARS", "[", "(", "(", "bb", "[", "i", "]", "&", "0xF0", ")", ">>", "4", ")", "]", ";", "ret", "[", "i", "*", "2", "+", "1", "]", "=", "HEXA_CHARS", "[", "(", "(", "bb", "[", "i", "]", "&", "0x0F", ")", ")", "]", ";", "}", "return", "new", "String", "(", "ret", ")", ";", "}" ]
Converts binary array into its hexadecimal representation. @param bb binary data @return hexadecimal string
[ "Converts", "binary", "array", "into", "its", "hexadecimal", "representation", "." ]
dfd873b2b9cc4e299228839c100adf93a98f1903
https://github.com/jankotek/mapdb/blob/dfd873b2b9cc4e299228839c100adf93a98f1903/src/main/java/org/mapdb/io/DataIO.java#L516-L524
17,037
jankotek/mapdb
src/main/java/org/mapdb/io/DataIO.java
DataIO.fromHexa
public static byte[] fromHexa(String s ) { byte[] ret = new byte[s.length()/2]; for(int i=0;i<ret.length;i++){ ret[i] = (byte) Integer.parseInt(s.substring(i*2,i*2+2),16); } return ret; }
java
public static byte[] fromHexa(String s ) { byte[] ret = new byte[s.length()/2]; for(int i=0;i<ret.length;i++){ ret[i] = (byte) Integer.parseInt(s.substring(i*2,i*2+2),16); } return ret; }
[ "public", "static", "byte", "[", "]", "fromHexa", "(", "String", "s", ")", "{", "byte", "[", "]", "ret", "=", "new", "byte", "[", "s", ".", "length", "(", ")", "/", "2", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ret", ".", "length", ";", "i", "++", ")", "{", "ret", "[", "i", "]", "=", "(", "byte", ")", "Integer", ".", "parseInt", "(", "s", ".", "substring", "(", "i", "*", "2", ",", "i", "*", "2", "+", "2", ")", ",", "16", ")", ";", "}", "return", "ret", ";", "}" ]
Converts hexadecimal string into binary data @param s hexadecimal string @return binary data @throws NumberFormatException in case of string format error
[ "Converts", "hexadecimal", "string", "into", "binary", "data" ]
dfd873b2b9cc4e299228839c100adf93a98f1903
https://github.com/jankotek/mapdb/blob/dfd873b2b9cc4e299228839c100adf93a98f1903/src/main/java/org/mapdb/io/DataIO.java#L532-L538
17,038
jankotek/mapdb
src/main/java/org/mapdb/io/DataIO.java
DataIO.isWindows
public static boolean isWindows(){ String os = System.getProperty("os.name"); return os!=null && os.toLowerCase().startsWith("windows"); }
java
public static boolean isWindows(){ String os = System.getProperty("os.name"); return os!=null && os.toLowerCase().startsWith("windows"); }
[ "public", "static", "boolean", "isWindows", "(", ")", "{", "String", "os", "=", "System", ".", "getProperty", "(", "\"os.name\"", ")", ";", "return", "os", "!=", "null", "&&", "os", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"windows\"", ")", ";", "}" ]
return true if operating system is Windows
[ "return", "true", "if", "operating", "system", "is", "Windows" ]
dfd873b2b9cc4e299228839c100adf93a98f1903
https://github.com/jankotek/mapdb/blob/dfd873b2b9cc4e299228839c100adf93a98f1903/src/main/java/org/mapdb/io/DataIO.java#L593-L596
17,039
jankotek/mapdb
src/main/java/org/mapdb/io/DataIO.java
DataIO.JVMSupportsLargeMappedFiles
public static boolean JVMSupportsLargeMappedFiles() { String arch = System.getProperty("os.arch"); if(arch==null || !arch.contains("64")) { return false; } if(isWindows()) return false; //TODO better check for 32bit JVM return true; }
java
public static boolean JVMSupportsLargeMappedFiles() { String arch = System.getProperty("os.arch"); if(arch==null || !arch.contains("64")) { return false; } if(isWindows()) return false; //TODO better check for 32bit JVM return true; }
[ "public", "static", "boolean", "JVMSupportsLargeMappedFiles", "(", ")", "{", "String", "arch", "=", "System", ".", "getProperty", "(", "\"os.arch\"", ")", ";", "if", "(", "arch", "==", "null", "||", "!", "arch", ".", "contains", "(", "\"64\"", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isWindows", "(", ")", ")", "return", "false", ";", "//TODO better check for 32bit JVM", "return", "true", ";", "}" ]
Check if large files can be mapped into memory. For example 32bit JVM can only address 2GB and large files can not be mapped, so for 32bit JVM this function returns false.
[ "Check", "if", "large", "files", "can", "be", "mapped", "into", "memory", ".", "For", "example", "32bit", "JVM", "can", "only", "address", "2GB", "and", "large", "files", "can", "not", "be", "mapped", "so", "for", "32bit", "JVM", "this", "function", "returns", "false", "." ]
dfd873b2b9cc4e299228839c100adf93a98f1903
https://github.com/jankotek/mapdb/blob/dfd873b2b9cc4e299228839c100adf93a98f1903/src/main/java/org/mapdb/io/DataIO.java#L604-L615
17,040
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/MapUtils.java
MapUtils.toSortedMap
public static <K, V> Map<K, V> toSortedMap(Map<K, V> map, Comparator<? super K> comparator) { Map<K, V> sortedMap; if (comparator == null) sortedMap = new LinkedHashMap<>(); else sortedMap = new TreeMap<>(comparator); sortedMap.putAll(map); return sortedMap; }
java
public static <K, V> Map<K, V> toSortedMap(Map<K, V> map, Comparator<? super K> comparator) { Map<K, V> sortedMap; if (comparator == null) sortedMap = new LinkedHashMap<>(); else sortedMap = new TreeMap<>(comparator); sortedMap.putAll(map); return sortedMap; }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "toSortedMap", "(", "Map", "<", "K", ",", "V", ">", "map", ",", "Comparator", "<", "?", "super", "K", ">", "comparator", ")", "{", "Map", "<", "K", ",", "V", ">", "sortedMap", ";", "if", "(", "comparator", "==", "null", ")", "sortedMap", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "else", "sortedMap", "=", "new", "TreeMap", "<>", "(", "comparator", ")", ";", "sortedMap", ".", "putAll", "(", "map", ")", ";", "return", "sortedMap", ";", "}" ]
Returns the the Map either ordered or as-is, if the comparator is null. @param map the Map @param comparator the comparator to use. @return the keySet of the Map
[ "Returns", "the", "the", "Map", "either", "ordered", "or", "as", "-", "is", "if", "the", "comparator", "is", "null", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/MapUtils.java#L32-L40
17,041
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/component/DefinitionComponent.java
DefinitionComponent.determineDefinitionTitle
private String determineDefinitionTitle(Parameters params) { if (params.model.getTitle() != null) { return params.model.getTitle(); } else { return params.definitionName; } }
java
private String determineDefinitionTitle(Parameters params) { if (params.model.getTitle() != null) { return params.model.getTitle(); } else { return params.definitionName; } }
[ "private", "String", "determineDefinitionTitle", "(", "Parameters", "params", ")", "{", "if", "(", "params", ".", "model", ".", "getTitle", "(", ")", "!=", "null", ")", "{", "return", "params", ".", "model", ".", "getTitle", "(", ")", ";", "}", "else", "{", "return", "params", ".", "definitionName", ";", "}", "}" ]
Determines title for definition. If title is present, it is used, definitionName is returned otherwise. @param params params object for this definition @return Definition title - value from title tag if present, definitionName otherwise
[ "Determines", "title", "for", "definition", ".", "If", "title", "is", "present", "it", "is", "used", "definitionName", "is", "returned", "otherwise", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/component/DefinitionComponent.java#L104-L110
17,042
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java
PropertyAdapter.generateExample
public static Object generateExample(Property property, MarkupDocBuilder markupDocBuilder) { if (property.getType() == null) { return "untyped"; } switch (property.getType()) { case "integer": return ExamplesUtil.generateIntegerExample(property instanceof IntegerProperty ? ((IntegerProperty) property).getEnum() : null); case "number": return 0.0; case "boolean": return true; case "string": return ExamplesUtil.generateStringExample(property.getFormat(), property instanceof StringProperty ? ((StringProperty) property).getEnum() : null); case "ref": if (property instanceof RefProperty) { if (logger.isDebugEnabled()) logger.debug("generateExample RefProperty for " + property.getName()); return markupDocBuilder.copy(false).crossReference(((RefProperty) property).getSimpleRef()).toString(); } else { if (logger.isDebugEnabled()) logger.debug("generateExample for ref not RefProperty"); } case "array": if (property instanceof ArrayProperty) { return generateArrayExample((ArrayProperty) property, markupDocBuilder); } default: return property.getType(); } }
java
public static Object generateExample(Property property, MarkupDocBuilder markupDocBuilder) { if (property.getType() == null) { return "untyped"; } switch (property.getType()) { case "integer": return ExamplesUtil.generateIntegerExample(property instanceof IntegerProperty ? ((IntegerProperty) property).getEnum() : null); case "number": return 0.0; case "boolean": return true; case "string": return ExamplesUtil.generateStringExample(property.getFormat(), property instanceof StringProperty ? ((StringProperty) property).getEnum() : null); case "ref": if (property instanceof RefProperty) { if (logger.isDebugEnabled()) logger.debug("generateExample RefProperty for " + property.getName()); return markupDocBuilder.copy(false).crossReference(((RefProperty) property).getSimpleRef()).toString(); } else { if (logger.isDebugEnabled()) logger.debug("generateExample for ref not RefProperty"); } case "array": if (property instanceof ArrayProperty) { return generateArrayExample((ArrayProperty) property, markupDocBuilder); } default: return property.getType(); } }
[ "public", "static", "Object", "generateExample", "(", "Property", "property", ",", "MarkupDocBuilder", "markupDocBuilder", ")", "{", "if", "(", "property", ".", "getType", "(", ")", "==", "null", ")", "{", "return", "\"untyped\"", ";", "}", "switch", "(", "property", ".", "getType", "(", ")", ")", "{", "case", "\"integer\"", ":", "return", "ExamplesUtil", ".", "generateIntegerExample", "(", "property", "instanceof", "IntegerProperty", "?", "(", "(", "IntegerProperty", ")", "property", ")", ".", "getEnum", "(", ")", ":", "null", ")", ";", "case", "\"number\"", ":", "return", "0.0", ";", "case", "\"boolean\"", ":", "return", "true", ";", "case", "\"string\"", ":", "return", "ExamplesUtil", ".", "generateStringExample", "(", "property", ".", "getFormat", "(", ")", ",", "property", "instanceof", "StringProperty", "?", "(", "(", "StringProperty", ")", "property", ")", ".", "getEnum", "(", ")", ":", "null", ")", ";", "case", "\"ref\"", ":", "if", "(", "property", "instanceof", "RefProperty", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "logger", ".", "debug", "(", "\"generateExample RefProperty for \"", "+", "property", ".", "getName", "(", ")", ")", ";", "return", "markupDocBuilder", ".", "copy", "(", "false", ")", ".", "crossReference", "(", "(", "(", "RefProperty", ")", "property", ")", ".", "getSimpleRef", "(", ")", ")", ".", "toString", "(", ")", ";", "}", "else", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "logger", ".", "debug", "(", "\"generateExample for ref not RefProperty\"", ")", ";", "}", "case", "\"array\"", ":", "if", "(", "property", "instanceof", "ArrayProperty", ")", "{", "return", "generateArrayExample", "(", "(", "ArrayProperty", ")", "property", ",", "markupDocBuilder", ")", ";", "}", "default", ":", "return", "property", ".", "getType", "(", ")", ";", "}", "}" ]
Generate a default example value for property. @param property property @param markupDocBuilder doc builder @return a generated example for the property
[ "Generate", "a", "default", "example", "value", "for", "property", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java#L76-L105
17,043
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java
PropertyAdapter.generateArrayExample
private static Object generateArrayExample(ArrayProperty property, MarkupDocBuilder markupDocBuilder) { Property itemProperty = property.getItems(); List<Object> exampleArray = new ArrayList<>(); exampleArray.add(generateExample(itemProperty, markupDocBuilder)); return exampleArray; }
java
private static Object generateArrayExample(ArrayProperty property, MarkupDocBuilder markupDocBuilder) { Property itemProperty = property.getItems(); List<Object> exampleArray = new ArrayList<>(); exampleArray.add(generateExample(itemProperty, markupDocBuilder)); return exampleArray; }
[ "private", "static", "Object", "generateArrayExample", "(", "ArrayProperty", "property", ",", "MarkupDocBuilder", "markupDocBuilder", ")", "{", "Property", "itemProperty", "=", "property", ".", "getItems", "(", ")", ";", "List", "<", "Object", ">", "exampleArray", "=", "new", "ArrayList", "<>", "(", ")", ";", "exampleArray", ".", "add", "(", "generateExample", "(", "itemProperty", ",", "markupDocBuilder", ")", ")", ";", "return", "exampleArray", ";", "}" ]
Generate example for an ArrayProperty @param property ArrayProperty to generate example for @param markupDocBuilder MarkupDocBuilder containing all associated settings @return String example
[ "Generate", "example", "for", "an", "ArrayProperty" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java#L114-L120
17,044
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java
PropertyAdapter.getDefaultValue
public Optional<Object> getDefaultValue() { if (property instanceof BooleanProperty) { BooleanProperty booleanProperty = (BooleanProperty) property; return Optional.ofNullable(booleanProperty.getDefault()); } else if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getDefault()); } else if (property instanceof DoubleProperty) { DoubleProperty doubleProperty = (DoubleProperty) property; return Optional.ofNullable(doubleProperty.getDefault()); } else if (property instanceof FloatProperty) { FloatProperty floatProperty = (FloatProperty) property; return Optional.ofNullable(floatProperty.getDefault()); } else if (property instanceof IntegerProperty) { IntegerProperty integerProperty = (IntegerProperty) property; return Optional.ofNullable(integerProperty.getDefault()); } else if (property instanceof LongProperty) { LongProperty longProperty = (LongProperty) property; return Optional.ofNullable(longProperty.getDefault()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getDefault()); } return Optional.empty(); }
java
public Optional<Object> getDefaultValue() { if (property instanceof BooleanProperty) { BooleanProperty booleanProperty = (BooleanProperty) property; return Optional.ofNullable(booleanProperty.getDefault()); } else if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getDefault()); } else if (property instanceof DoubleProperty) { DoubleProperty doubleProperty = (DoubleProperty) property; return Optional.ofNullable(doubleProperty.getDefault()); } else if (property instanceof FloatProperty) { FloatProperty floatProperty = (FloatProperty) property; return Optional.ofNullable(floatProperty.getDefault()); } else if (property instanceof IntegerProperty) { IntegerProperty integerProperty = (IntegerProperty) property; return Optional.ofNullable(integerProperty.getDefault()); } else if (property instanceof LongProperty) { LongProperty longProperty = (LongProperty) property; return Optional.ofNullable(longProperty.getDefault()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getDefault()); } return Optional.empty(); }
[ "public", "Optional", "<", "Object", ">", "getDefaultValue", "(", ")", "{", "if", "(", "property", "instanceof", "BooleanProperty", ")", "{", "BooleanProperty", "booleanProperty", "=", "(", "BooleanProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "booleanProperty", ".", "getDefault", "(", ")", ")", ";", "}", "else", "if", "(", "property", "instanceof", "StringProperty", ")", "{", "StringProperty", "stringProperty", "=", "(", "StringProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "stringProperty", ".", "getDefault", "(", ")", ")", ";", "}", "else", "if", "(", "property", "instanceof", "DoubleProperty", ")", "{", "DoubleProperty", "doubleProperty", "=", "(", "DoubleProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "doubleProperty", ".", "getDefault", "(", ")", ")", ";", "}", "else", "if", "(", "property", "instanceof", "FloatProperty", ")", "{", "FloatProperty", "floatProperty", "=", "(", "FloatProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "floatProperty", ".", "getDefault", "(", ")", ")", ";", "}", "else", "if", "(", "property", "instanceof", "IntegerProperty", ")", "{", "IntegerProperty", "integerProperty", "=", "(", "IntegerProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "integerProperty", ".", "getDefault", "(", ")", ")", ";", "}", "else", "if", "(", "property", "instanceof", "LongProperty", ")", "{", "LongProperty", "longProperty", "=", "(", "LongProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "longProperty", ".", "getDefault", "(", ")", ")", ";", "}", "else", "if", "(", "property", "instanceof", "UUIDProperty", ")", "{", "UUIDProperty", "uuidProperty", "=", "(", "UUIDProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "uuidProperty", ".", "getDefault", "(", ")", ")", ";", "}", "return", "Optional", ".", "empty", "(", ")", ";", "}" ]
Retrieves the default value of a property @return the default value of the property
[ "Retrieves", "the", "default", "value", "of", "a", "property" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java#L226-L250
17,045
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java
PropertyAdapter.getMinlength
public Optional<Integer> getMinlength() { if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getMinLength()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getMinLength()); } return Optional.empty(); }
java
public Optional<Integer> getMinlength() { if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getMinLength()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getMinLength()); } return Optional.empty(); }
[ "public", "Optional", "<", "Integer", ">", "getMinlength", "(", ")", "{", "if", "(", "property", "instanceof", "StringProperty", ")", "{", "StringProperty", "stringProperty", "=", "(", "StringProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "stringProperty", ".", "getMinLength", "(", ")", ")", ";", "}", "else", "if", "(", "property", "instanceof", "UUIDProperty", ")", "{", "UUIDProperty", "uuidProperty", "=", "(", "UUIDProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "uuidProperty", ".", "getMinLength", "(", ")", ")", ";", "}", "return", "Optional", ".", "empty", "(", ")", ";", "}" ]
Retrieves the minLength of a property @return the minLength of the property
[ "Retrieves", "the", "minLength", "of", "a", "property" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java#L257-L266
17,046
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java
PropertyAdapter.getMaxlength
public Optional<Integer> getMaxlength() { if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getMaxLength()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getMaxLength()); } return Optional.empty(); }
java
public Optional<Integer> getMaxlength() { if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getMaxLength()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getMaxLength()); } return Optional.empty(); }
[ "public", "Optional", "<", "Integer", ">", "getMaxlength", "(", ")", "{", "if", "(", "property", "instanceof", "StringProperty", ")", "{", "StringProperty", "stringProperty", "=", "(", "StringProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "stringProperty", ".", "getMaxLength", "(", ")", ")", ";", "}", "else", "if", "(", "property", "instanceof", "UUIDProperty", ")", "{", "UUIDProperty", "uuidProperty", "=", "(", "UUIDProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "uuidProperty", ".", "getMaxLength", "(", ")", ")", ";", "}", "return", "Optional", ".", "empty", "(", ")", ";", "}" ]
Retrieves the maxLength of a property @return the maxLength of the property
[ "Retrieves", "the", "maxLength", "of", "a", "property" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java#L273-L282
17,047
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java
PropertyAdapter.getPattern
public Optional<String> getPattern() { if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getPattern()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getPattern()); } return Optional.empty(); }
java
public Optional<String> getPattern() { if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getPattern()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getPattern()); } return Optional.empty(); }
[ "public", "Optional", "<", "String", ">", "getPattern", "(", ")", "{", "if", "(", "property", "instanceof", "StringProperty", ")", "{", "StringProperty", "stringProperty", "=", "(", "StringProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "stringProperty", ".", "getPattern", "(", ")", ")", ";", "}", "else", "if", "(", "property", "instanceof", "UUIDProperty", ")", "{", "UUIDProperty", "uuidProperty", "=", "(", "UUIDProperty", ")", "property", ";", "return", "Optional", ".", "ofNullable", "(", "uuidProperty", ".", "getPattern", "(", ")", ")", ";", "}", "return", "Optional", ".", "empty", "(", ")", ";", "}" ]
Retrieves the pattern of a property @return the pattern of the property
[ "Retrieves", "the", "pattern", "of", "a", "property" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java#L289-L298
17,048
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java
PropertyAdapter.getExclusiveMin
public boolean getExclusiveMin() { if (property instanceof AbstractNumericProperty) { AbstractNumericProperty numericProperty = (AbstractNumericProperty) property; return BooleanUtils.isTrue(numericProperty.getExclusiveMinimum()); } return false; }
java
public boolean getExclusiveMin() { if (property instanceof AbstractNumericProperty) { AbstractNumericProperty numericProperty = (AbstractNumericProperty) property; return BooleanUtils.isTrue(numericProperty.getExclusiveMinimum()); } return false; }
[ "public", "boolean", "getExclusiveMin", "(", ")", "{", "if", "(", "property", "instanceof", "AbstractNumericProperty", ")", "{", "AbstractNumericProperty", "numericProperty", "=", "(", "AbstractNumericProperty", ")", "property", ";", "return", "BooleanUtils", ".", "isTrue", "(", "numericProperty", ".", "getExclusiveMinimum", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Retrieves the exclusiveMinimum value of a property @return the exclusiveMinimum value of the property
[ "Retrieves", "the", "exclusiveMinimum", "value", "of", "a", "property" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java#L321-L327
17,049
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java
PropertyAdapter.getExclusiveMax
public boolean getExclusiveMax() { if (property instanceof AbstractNumericProperty) { AbstractNumericProperty numericProperty = (AbstractNumericProperty) property; return BooleanUtils.isTrue((numericProperty.getExclusiveMaximum())); } return false; }
java
public boolean getExclusiveMax() { if (property instanceof AbstractNumericProperty) { AbstractNumericProperty numericProperty = (AbstractNumericProperty) property; return BooleanUtils.isTrue((numericProperty.getExclusiveMaximum())); } return false; }
[ "public", "boolean", "getExclusiveMax", "(", ")", "{", "if", "(", "property", "instanceof", "AbstractNumericProperty", ")", "{", "AbstractNumericProperty", "numericProperty", "=", "(", "AbstractNumericProperty", ")", "property", ";", "return", "BooleanUtils", ".", "isTrue", "(", "(", "numericProperty", ".", "getExclusiveMaximum", "(", ")", ")", ")", ";", "}", "return", "false", ";", "}" ]
Retrieves the exclusiveMaximum value of a property @return the exclusiveMaximum value of the property
[ "Retrieves", "the", "exclusiveMaximum", "value", "of", "a", "property" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java#L350-L356
17,050
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.getDefaultConfiguration
private Configuration getDefaultConfiguration() { Configurations configs = new Configurations(); try { return configs.properties(PROPERTIES_DEFAULT); } catch (ConfigurationException e) { throw new RuntimeException(String.format("Can't load default properties '%s'", PROPERTIES_DEFAULT), e); } }
java
private Configuration getDefaultConfiguration() { Configurations configs = new Configurations(); try { return configs.properties(PROPERTIES_DEFAULT); } catch (ConfigurationException e) { throw new RuntimeException(String.format("Can't load default properties '%s'", PROPERTIES_DEFAULT), e); } }
[ "private", "Configuration", "getDefaultConfiguration", "(", ")", "{", "Configurations", "configs", "=", "new", "Configurations", "(", ")", ";", "try", "{", "return", "configs", ".", "properties", "(", "PROPERTIES_DEFAULT", ")", ";", "}", "catch", "(", "ConfigurationException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "String", ".", "format", "(", "\"Can't load default properties '%s'\"", ",", "PROPERTIES_DEFAULT", ")", ",", "e", ")", ";", "}", "}" ]
Loads the default properties from the classpath. @return the default properties
[ "Loads", "the", "default", "properties", "from", "the", "classpath", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L134-L141
17,051
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withMarkupLanguage
public Swagger2MarkupConfigBuilder withMarkupLanguage(MarkupLanguage markupLanguage) { Validate.notNull(markupLanguage, "%s must not be null", "markupLanguage"); config.markupLanguage = markupLanguage; return this; }
java
public Swagger2MarkupConfigBuilder withMarkupLanguage(MarkupLanguage markupLanguage) { Validate.notNull(markupLanguage, "%s must not be null", "markupLanguage"); config.markupLanguage = markupLanguage; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withMarkupLanguage", "(", "MarkupLanguage", "markupLanguage", ")", "{", "Validate", ".", "notNull", "(", "markupLanguage", ",", "\"%s must not be null\"", ",", "\"markupLanguage\"", ")", ";", "config", ".", "markupLanguage", "=", "markupLanguage", ";", "return", "this", ";", "}" ]
Specifies the markup language which should be used to generate the files. @param markupLanguage the markup language which is used to generate the files @return this builder
[ "Specifies", "the", "markup", "language", "which", "should", "be", "used", "to", "generate", "the", "files", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L175-L179
17,052
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withSwaggerMarkupLanguage
public Swagger2MarkupConfigBuilder withSwaggerMarkupLanguage(MarkupLanguage swaggerMarkupLanguage) { Validate.notNull(swaggerMarkupLanguage, "%s must not be null", "swaggerMarkupLanguage"); config.swaggerMarkupLanguage = swaggerMarkupLanguage; return this; }
java
public Swagger2MarkupConfigBuilder withSwaggerMarkupLanguage(MarkupLanguage swaggerMarkupLanguage) { Validate.notNull(swaggerMarkupLanguage, "%s must not be null", "swaggerMarkupLanguage"); config.swaggerMarkupLanguage = swaggerMarkupLanguage; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withSwaggerMarkupLanguage", "(", "MarkupLanguage", "swaggerMarkupLanguage", ")", "{", "Validate", ".", "notNull", "(", "swaggerMarkupLanguage", ",", "\"%s must not be null\"", ",", "\"swaggerMarkupLanguage\"", ")", ";", "config", ".", "swaggerMarkupLanguage", "=", "swaggerMarkupLanguage", ";", "return", "this", ";", "}" ]
Specifies the markup language used in Swagger descriptions. @param swaggerMarkupLanguage the markup language used in Swagger descriptions @return this builder
[ "Specifies", "the", "markup", "language", "used", "in", "Swagger", "descriptions", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L187-L191
17,053
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withListDelimiter
public Swagger2MarkupConfigBuilder withListDelimiter(Character delimiter) { Validate.notNull(delimiter, "%s must not be null", "delimiter"); config.listDelimiter = delimiter; config.listDelimiterEnabled = true; return this; }
java
public Swagger2MarkupConfigBuilder withListDelimiter(Character delimiter) { Validate.notNull(delimiter, "%s must not be null", "delimiter"); config.listDelimiter = delimiter; config.listDelimiterEnabled = true; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withListDelimiter", "(", "Character", "delimiter", ")", "{", "Validate", ".", "notNull", "(", "delimiter", ",", "\"%s must not be null\"", ",", "\"delimiter\"", ")", ";", "config", ".", "listDelimiter", "=", "delimiter", ";", "config", ".", "listDelimiterEnabled", "=", "true", ";", "return", "this", ";", "}" ]
Specifies the list delimiter which should be used. @param delimiter the delimiter @return this builder
[ "Specifies", "the", "list", "delimiter", "which", "should", "be", "used", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L239-L244
17,054
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withPathsGroupedBy
public Swagger2MarkupConfigBuilder withPathsGroupedBy(GroupBy pathsGroupedBy) { Validate.notNull(pathsGroupedBy, "%s must not be null", "pathsGroupedBy"); config.pathsGroupedBy = pathsGroupedBy; return this; }
java
public Swagger2MarkupConfigBuilder withPathsGroupedBy(GroupBy pathsGroupedBy) { Validate.notNull(pathsGroupedBy, "%s must not be null", "pathsGroupedBy"); config.pathsGroupedBy = pathsGroupedBy; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withPathsGroupedBy", "(", "GroupBy", "pathsGroupedBy", ")", "{", "Validate", ".", "notNull", "(", "pathsGroupedBy", ",", "\"%s must not be null\"", ",", "\"pathsGroupedBy\"", ")", ";", "config", ".", "pathsGroupedBy", "=", "pathsGroupedBy", ";", "return", "this", ";", "}" ]
Specifies if the paths should be grouped by tags or stay as-is. @param pathsGroupedBy the GroupBy enum @return this builder
[ "Specifies", "if", "the", "paths", "should", "be", "grouped", "by", "tags", "or", "stay", "as", "-", "is", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L253-L257
17,055
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withHeaderRegex
public Swagger2MarkupConfigBuilder withHeaderRegex(String headerRegex) { Validate.notNull(headerRegex, "%s must not be null", headerRegex); config.headerPattern = Pattern.compile(headerRegex); return this; }
java
public Swagger2MarkupConfigBuilder withHeaderRegex(String headerRegex) { Validate.notNull(headerRegex, "%s must not be null", headerRegex); config.headerPattern = Pattern.compile(headerRegex); return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withHeaderRegex", "(", "String", "headerRegex", ")", "{", "Validate", ".", "notNull", "(", "headerRegex", ",", "\"%s must not be null\"", ",", "headerRegex", ")", ";", "config", ".", "headerPattern", "=", "Pattern", ".", "compile", "(", "headerRegex", ")", ";", "return", "this", ";", "}" ]
Specifies the regex pattern to use for grouping paths. @param headerRegex regex pattern string containing one capture group @return this builder @throws PatternSyntaxException when pattern cannot be compiled
[ "Specifies", "the", "regex", "pattern", "to", "use", "for", "grouping", "paths", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L266-L270
17,056
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withOutputLanguage
public Swagger2MarkupConfigBuilder withOutputLanguage(Language language) { Validate.notNull(language, "%s must not be null", "language"); config.outputLanguage = language; return this; }
java
public Swagger2MarkupConfigBuilder withOutputLanguage(Language language) { Validate.notNull(language, "%s must not be null", "language"); config.outputLanguage = language; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withOutputLanguage", "(", "Language", "language", ")", "{", "Validate", ".", "notNull", "(", "language", ",", "\"%s must not be null\"", ",", "\"language\"", ")", ";", "config", ".", "outputLanguage", "=", "language", ";", "return", "this", ";", "}" ]
Specifies labels language of output files. @param language the enum @return this builder
[ "Specifies", "labels", "language", "of", "output", "files", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L278-L282
17,057
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withTagOrdering
public Swagger2MarkupConfigBuilder withTagOrdering(Comparator<String> tagOrdering) { Validate.notNull(tagOrdering, "%s must not be null", "tagOrdering"); config.tagOrderBy = OrderBy.CUSTOM; config.tagOrdering = tagOrdering; return this; }
java
public Swagger2MarkupConfigBuilder withTagOrdering(Comparator<String> tagOrdering) { Validate.notNull(tagOrdering, "%s must not be null", "tagOrdering"); config.tagOrderBy = OrderBy.CUSTOM; config.tagOrdering = tagOrdering; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withTagOrdering", "(", "Comparator", "<", "String", ">", "tagOrdering", ")", "{", "Validate", ".", "notNull", "(", "tagOrdering", ",", "\"%s must not be null\"", ",", "\"tagOrdering\"", ")", ";", "config", ".", "tagOrderBy", "=", "OrderBy", ".", "CUSTOM", ";", "config", ".", "tagOrdering", "=", "tagOrdering", ";", "return", "this", ";", "}" ]
Specifies a custom comparator function to order tags. @param tagOrdering tag ordering @return this builder
[ "Specifies", "a", "custom", "comparator", "function", "to", "order", "tags", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L315-L320
17,058
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withOperationOrdering
public Swagger2MarkupConfigBuilder withOperationOrdering(Comparator<PathOperation> operationOrdering) { Validate.notNull(operationOrdering, "%s must not be null", "operationOrdering"); config.operationOrderBy = OrderBy.CUSTOM; config.operationOrdering = operationOrdering; return this; }
java
public Swagger2MarkupConfigBuilder withOperationOrdering(Comparator<PathOperation> operationOrdering) { Validate.notNull(operationOrdering, "%s must not be null", "operationOrdering"); config.operationOrderBy = OrderBy.CUSTOM; config.operationOrdering = operationOrdering; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withOperationOrdering", "(", "Comparator", "<", "PathOperation", ">", "operationOrdering", ")", "{", "Validate", ".", "notNull", "(", "operationOrdering", ",", "\"%s must not be null\"", ",", "\"operationOrdering\"", ")", ";", "config", ".", "operationOrderBy", "=", "OrderBy", ".", "CUSTOM", ";", "config", ".", "operationOrdering", "=", "operationOrdering", ";", "return", "this", ";", "}" ]
Specifies a custom comparator function to order operations. @param operationOrdering operation ordering @return this builder
[ "Specifies", "a", "custom", "comparator", "function", "to", "order", "operations", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L343-L348
17,059
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withDefinitionOrdering
public Swagger2MarkupConfigBuilder withDefinitionOrdering(Comparator<String> definitionOrdering) { Validate.notNull(definitionOrdering, "%s must not be null", "definitionOrdering"); config.definitionOrderBy = OrderBy.CUSTOM; config.definitionOrdering = definitionOrdering; return this; }
java
public Swagger2MarkupConfigBuilder withDefinitionOrdering(Comparator<String> definitionOrdering) { Validate.notNull(definitionOrdering, "%s must not be null", "definitionOrdering"); config.definitionOrderBy = OrderBy.CUSTOM; config.definitionOrdering = definitionOrdering; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withDefinitionOrdering", "(", "Comparator", "<", "String", ">", "definitionOrdering", ")", "{", "Validate", ".", "notNull", "(", "definitionOrdering", ",", "\"%s must not be null\"", ",", "\"definitionOrdering\"", ")", ";", "config", ".", "definitionOrderBy", "=", "OrderBy", ".", "CUSTOM", ";", "config", ".", "definitionOrdering", "=", "definitionOrdering", ";", "return", "this", ";", "}" ]
Specifies a custom comparator function to order definitions. @param definitionOrdering definition ordering @return this builder
[ "Specifies", "a", "custom", "comparator", "function", "to", "order", "definitions", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L371-L376
17,060
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withParameterOrdering
public Swagger2MarkupConfigBuilder withParameterOrdering(Comparator<Parameter> parameterOrdering) { Validate.notNull(parameterOrdering, "%s must not be null", "parameterOrdering"); config.parameterOrderBy = OrderBy.CUSTOM; config.parameterOrdering = parameterOrdering; return this; }
java
public Swagger2MarkupConfigBuilder withParameterOrdering(Comparator<Parameter> parameterOrdering) { Validate.notNull(parameterOrdering, "%s must not be null", "parameterOrdering"); config.parameterOrderBy = OrderBy.CUSTOM; config.parameterOrdering = parameterOrdering; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withParameterOrdering", "(", "Comparator", "<", "Parameter", ">", "parameterOrdering", ")", "{", "Validate", ".", "notNull", "(", "parameterOrdering", ",", "\"%s must not be null\"", ",", "\"parameterOrdering\"", ")", ";", "config", ".", "parameterOrderBy", "=", "OrderBy", ".", "CUSTOM", ";", "config", ".", "parameterOrdering", "=", "parameterOrdering", ";", "return", "this", ";", "}" ]
Specifies a custom comparator function to order parameters. @param parameterOrdering parameter ordering @return this builder
[ "Specifies", "a", "custom", "comparator", "function", "to", "order", "parameters", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L399-L405
17,061
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withPropertyOrdering
public Swagger2MarkupConfigBuilder withPropertyOrdering(Comparator<String> propertyOrdering) { Validate.notNull(propertyOrdering, "%s must not be null", "propertyOrdering"); config.propertyOrderBy = OrderBy.CUSTOM; config.propertyOrdering = propertyOrdering; return this; }
java
public Swagger2MarkupConfigBuilder withPropertyOrdering(Comparator<String> propertyOrdering) { Validate.notNull(propertyOrdering, "%s must not be null", "propertyOrdering"); config.propertyOrderBy = OrderBy.CUSTOM; config.propertyOrdering = propertyOrdering; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withPropertyOrdering", "(", "Comparator", "<", "String", ">", "propertyOrdering", ")", "{", "Validate", ".", "notNull", "(", "propertyOrdering", ",", "\"%s must not be null\"", ",", "\"propertyOrdering\"", ")", ";", "config", ".", "propertyOrderBy", "=", "OrderBy", ".", "CUSTOM", ";", "config", ".", "propertyOrdering", "=", "propertyOrdering", ";", "return", "this", ";", "}" ]
Specifies a custom comparator function to order properties. @param propertyOrdering property ordering @return this builder
[ "Specifies", "a", "custom", "comparator", "function", "to", "order", "properties", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L428-L434
17,062
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withResponseOrdering
public Swagger2MarkupConfigBuilder withResponseOrdering(Comparator<String> responseOrdering) { Validate.notNull(responseOrdering, "%s must not be null", "responseOrdering"); config.responseOrderBy = OrderBy.CUSTOM; config.responseOrdering = responseOrdering; return this; }
java
public Swagger2MarkupConfigBuilder withResponseOrdering(Comparator<String> responseOrdering) { Validate.notNull(responseOrdering, "%s must not be null", "responseOrdering"); config.responseOrderBy = OrderBy.CUSTOM; config.responseOrdering = responseOrdering; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withResponseOrdering", "(", "Comparator", "<", "String", ">", "responseOrdering", ")", "{", "Validate", ".", "notNull", "(", "responseOrdering", ",", "\"%s must not be null\"", ",", "\"responseOrdering\"", ")", ";", "config", ".", "responseOrderBy", "=", "OrderBy", ".", "CUSTOM", ";", "config", ".", "responseOrdering", "=", "responseOrdering", ";", "return", "this", ";", "}" ]
Specifies a custom comparator function to order responses. @param responseOrdering response ordering @return this builder
[ "Specifies", "a", "custom", "comparator", "function", "to", "order", "responses", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L457-L463
17,063
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withInterDocumentCrossReferences
public Swagger2MarkupConfigBuilder withInterDocumentCrossReferences(String prefix) { Validate.notNull(prefix, "%s must not be null", "prefix"); config.interDocumentCrossReferencesEnabled = true; config.interDocumentCrossReferencesPrefix = prefix; return this; }
java
public Swagger2MarkupConfigBuilder withInterDocumentCrossReferences(String prefix) { Validate.notNull(prefix, "%s must not be null", "prefix"); config.interDocumentCrossReferencesEnabled = true; config.interDocumentCrossReferencesPrefix = prefix; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withInterDocumentCrossReferences", "(", "String", "prefix", ")", "{", "Validate", ".", "notNull", "(", "prefix", ",", "\"%s must not be null\"", ",", "\"prefix\"", ")", ";", "config", ".", "interDocumentCrossReferencesEnabled", "=", "true", ";", "config", ".", "interDocumentCrossReferencesPrefix", "=", "prefix", ";", "return", "this", ";", "}" ]
Enable use of inter-document cross-references when needed. @param prefix Prefix to document in all inter-document cross-references. @return this builder
[ "Enable", "use", "of", "inter", "-", "document", "cross", "-", "references", "when", "needed", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L471-L476
17,064
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withAnchorPrefix
public Swagger2MarkupConfigBuilder withAnchorPrefix(String anchorPrefix) { Validate.notNull(anchorPrefix, "%s must not be null", "anchorPrefix"); config.anchorPrefix = anchorPrefix; return this; }
java
public Swagger2MarkupConfigBuilder withAnchorPrefix(String anchorPrefix) { Validate.notNull(anchorPrefix, "%s must not be null", "anchorPrefix"); config.anchorPrefix = anchorPrefix; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withAnchorPrefix", "(", "String", "anchorPrefix", ")", "{", "Validate", ".", "notNull", "(", "anchorPrefix", ",", "\"%s must not be null\"", ",", "\"anchorPrefix\"", ")", ";", "config", ".", "anchorPrefix", "=", "anchorPrefix", ";", "return", "this", ";", "}" ]
Optionally prefix all anchors for uniqueness. @param anchorPrefix anchor prefix. @return this builder
[ "Optionally", "prefix", "all", "anchors", "for", "uniqueness", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L524-L528
17,065
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withPageBreaks
public Swagger2MarkupConfigBuilder withPageBreaks(List<PageBreakLocations> locations) { Validate.notNull(locations, "%s must not be null", "locations"); config.pageBreakLocations = locations; return this; }
java
public Swagger2MarkupConfigBuilder withPageBreaks(List<PageBreakLocations> locations) { Validate.notNull(locations, "%s must not be null", "locations"); config.pageBreakLocations = locations; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withPageBreaks", "(", "List", "<", "PageBreakLocations", ">", "locations", ")", "{", "Validate", ".", "notNull", "(", "locations", ",", "\"%s must not be null\"", ",", "\"locations\"", ")", ";", "config", ".", "pageBreakLocations", "=", "locations", ";", "return", "this", ";", "}" ]
Set the page break locations @param locations List of locations to create new pages @return this builder
[ "Set", "the", "page", "break", "locations" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L536-L540
17,066
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java
Swagger2MarkupConfigBuilder.withLineSeparator
public Swagger2MarkupConfigBuilder withLineSeparator(LineSeparator lineSeparator) { Validate.notNull(lineSeparator, "%s must no be null", "lineSeparator"); config.lineSeparator = lineSeparator; return this; }
java
public Swagger2MarkupConfigBuilder withLineSeparator(LineSeparator lineSeparator) { Validate.notNull(lineSeparator, "%s must no be null", "lineSeparator"); config.lineSeparator = lineSeparator; return this; }
[ "public", "Swagger2MarkupConfigBuilder", "withLineSeparator", "(", "LineSeparator", "lineSeparator", ")", "{", "Validate", ".", "notNull", "(", "lineSeparator", ",", "\"%s must no be null\"", ",", "\"lineSeparator\"", ")", ";", "config", ".", "lineSeparator", "=", "lineSeparator", ";", "return", "this", ";", "}" ]
Specifies the line separator which should be used. @param lineSeparator the lineSeparator @return this builder
[ "Specifies", "the", "line", "separator", "which", "should", "be", "used", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/builder/Swagger2MarkupConfigBuilder.java#L548-L552
17,067
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/Swagger2MarkupProperties.java
Swagger2MarkupProperties.getString
public Optional<String> getString(String key) { return Optional.ofNullable(configuration.getString(key)); }
java
public Optional<String> getString(String key) { return Optional.ofNullable(configuration.getString(key)); }
[ "public", "Optional", "<", "String", ">", "getString", "(", "String", "key", ")", "{", "return", "Optional", ".", "ofNullable", "(", "configuration", ".", "getString", "(", "key", ")", ")", ";", "}" ]
Returns an optional String property value associated with the given key. @param key the property name to resolve @return The string property
[ "Returns", "an", "optional", "String", "property", "value", "associated", "with", "the", "given", "key", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/Swagger2MarkupProperties.java#L99-L101
17,068
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/Swagger2MarkupProperties.java
Swagger2MarkupProperties.getInteger
public Optional<Integer> getInteger(String key) { return Optional.ofNullable(configuration.getInteger(key, null)); }
java
public Optional<Integer> getInteger(String key) { return Optional.ofNullable(configuration.getInteger(key, null)); }
[ "public", "Optional", "<", "Integer", ">", "getInteger", "(", "String", "key", ")", "{", "return", "Optional", ".", "ofNullable", "(", "configuration", ".", "getInteger", "(", "key", ",", "null", ")", ")", ";", "}" ]
Returns an optional Integer property value associated with the given key. @param key the property name to resolve @return An optional Integer property
[ "Returns", "an", "optional", "Integer", "property", "value", "associated", "with", "the", "given", "key", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/Swagger2MarkupProperties.java#L133-L135
17,069
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java
PathOperationComponent.buildOperationTitle
private void buildOperationTitle(MarkupDocBuilder markupDocBuilder, PathOperation operation) { buildOperationTitle(markupDocBuilder, operation.getTitle(), operation.getId()); if (operation.getTitle().equals(operation.getOperation().getSummary())) { markupDocBuilder.block(operation.getMethod() + " " + operation.getPath(), MarkupBlockStyle.LITERAL); } }
java
private void buildOperationTitle(MarkupDocBuilder markupDocBuilder, PathOperation operation) { buildOperationTitle(markupDocBuilder, operation.getTitle(), operation.getId()); if (operation.getTitle().equals(operation.getOperation().getSummary())) { markupDocBuilder.block(operation.getMethod() + " " + operation.getPath(), MarkupBlockStyle.LITERAL); } }
[ "private", "void", "buildOperationTitle", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "PathOperation", "operation", ")", "{", "buildOperationTitle", "(", "markupDocBuilder", ",", "operation", ".", "getTitle", "(", ")", ",", "operation", ".", "getId", "(", ")", ")", ";", "if", "(", "operation", ".", "getTitle", "(", ")", ".", "equals", "(", "operation", ".", "getOperation", "(", ")", ".", "getSummary", "(", ")", ")", ")", "{", "markupDocBuilder", ".", "block", "(", "operation", ".", "getMethod", "(", ")", "+", "\" \"", "+", "operation", ".", "getPath", "(", ")", ",", "MarkupBlockStyle", ".", "LITERAL", ")", ";", "}", "}" ]
Adds the operation title to the document. If the operation has a summary, the title is the summary. Otherwise the title is the method of the operation and the URL of the operation. @param operation the Swagger Operation
[ "Adds", "the", "operation", "title", "to", "the", "document", ".", "If", "the", "operation", "has", "a", "summary", "the", "title", "is", "the", "summary", ".", "Otherwise", "the", "title", "is", "the", "method", "of", "the", "operation", "and", "the", "URL", "of", "the", "operation", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java#L135-L140
17,070
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java
PathOperationComponent.buildOperationTitle
private void buildOperationTitle(MarkupDocBuilder markupDocBuilder, String title, String anchor) { if (config.getPathsGroupedBy() == GroupBy.AS_IS) { markupDocBuilder.sectionTitleWithAnchorLevel2(title, anchor); } else { markupDocBuilder.sectionTitleWithAnchorLevel3(title, anchor); } }
java
private void buildOperationTitle(MarkupDocBuilder markupDocBuilder, String title, String anchor) { if (config.getPathsGroupedBy() == GroupBy.AS_IS) { markupDocBuilder.sectionTitleWithAnchorLevel2(title, anchor); } else { markupDocBuilder.sectionTitleWithAnchorLevel3(title, anchor); } }
[ "private", "void", "buildOperationTitle", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "String", "title", ",", "String", "anchor", ")", "{", "if", "(", "config", ".", "getPathsGroupedBy", "(", ")", "==", "GroupBy", ".", "AS_IS", ")", "{", "markupDocBuilder", ".", "sectionTitleWithAnchorLevel2", "(", "title", ",", "anchor", ")", ";", "}", "else", "{", "markupDocBuilder", ".", "sectionTitleWithAnchorLevel3", "(", "title", ",", "anchor", ")", ";", "}", "}" ]
Adds a operation title to the document. @param title the operation title @param anchor optional anchor (null => auto-generate from title)
[ "Adds", "a", "operation", "title", "to", "the", "document", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java#L148-L154
17,071
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java
PathOperationComponent.buildDeprecatedSection
private void buildDeprecatedSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { if (BooleanUtils.isTrue(operation.getOperation().isDeprecated())) { markupDocBuilder.block(DEPRECATED_OPERATION, MarkupBlockStyle.EXAMPLE, null, MarkupAdmonition.CAUTION); } }
java
private void buildDeprecatedSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { if (BooleanUtils.isTrue(operation.getOperation().isDeprecated())) { markupDocBuilder.block(DEPRECATED_OPERATION, MarkupBlockStyle.EXAMPLE, null, MarkupAdmonition.CAUTION); } }
[ "private", "void", "buildDeprecatedSection", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "PathOperation", "operation", ")", "{", "if", "(", "BooleanUtils", ".", "isTrue", "(", "operation", ".", "getOperation", "(", ")", ".", "isDeprecated", "(", ")", ")", ")", "{", "markupDocBuilder", ".", "block", "(", "DEPRECATED_OPERATION", ",", "MarkupBlockStyle", ".", "EXAMPLE", ",", "null", ",", "MarkupAdmonition", ".", "CAUTION", ")", ";", "}", "}" ]
Builds a warning if method is deprecated. @param operation the Swagger Operation
[ "Builds", "a", "warning", "if", "method", "is", "deprecated", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java#L161-L165
17,072
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java
PathOperationComponent.buildDescriptionSection
private void buildDescriptionSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { MarkupDocBuilder descriptionBuilder = copyMarkupDocBuilder(markupDocBuilder); applyPathsDocumentExtension(new PathsDocumentExtension.Context(Position.OPERATION_DESCRIPTION_BEGIN, descriptionBuilder, operation)); String description = operation.getOperation().getDescription(); if (isNotBlank(description)) { descriptionBuilder.paragraph(markupDescription(config.getSwaggerMarkupLanguage(), markupDocBuilder, description)); } applyPathsDocumentExtension(new PathsDocumentExtension.Context(Position.OPERATION_DESCRIPTION_END, descriptionBuilder, operation)); String descriptionContent = descriptionBuilder.toString(); applyPathsDocumentExtension(new PathsDocumentExtension.Context(Position.OPERATION_DESCRIPTION_BEFORE, markupDocBuilder, operation)); if (isNotBlank(descriptionContent)) { buildSectionTitle(markupDocBuilder, labels.getLabel(DESCRIPTION)); markupDocBuilder.text(descriptionContent); } applyPathsDocumentExtension(new PathsDocumentExtension.Context(Position.OPERATION_DESCRIPTION_AFTER, markupDocBuilder, operation)); }
java
private void buildDescriptionSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { MarkupDocBuilder descriptionBuilder = copyMarkupDocBuilder(markupDocBuilder); applyPathsDocumentExtension(new PathsDocumentExtension.Context(Position.OPERATION_DESCRIPTION_BEGIN, descriptionBuilder, operation)); String description = operation.getOperation().getDescription(); if (isNotBlank(description)) { descriptionBuilder.paragraph(markupDescription(config.getSwaggerMarkupLanguage(), markupDocBuilder, description)); } applyPathsDocumentExtension(new PathsDocumentExtension.Context(Position.OPERATION_DESCRIPTION_END, descriptionBuilder, operation)); String descriptionContent = descriptionBuilder.toString(); applyPathsDocumentExtension(new PathsDocumentExtension.Context(Position.OPERATION_DESCRIPTION_BEFORE, markupDocBuilder, operation)); if (isNotBlank(descriptionContent)) { buildSectionTitle(markupDocBuilder, labels.getLabel(DESCRIPTION)); markupDocBuilder.text(descriptionContent); } applyPathsDocumentExtension(new PathsDocumentExtension.Context(Position.OPERATION_DESCRIPTION_AFTER, markupDocBuilder, operation)); }
[ "private", "void", "buildDescriptionSection", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "PathOperation", "operation", ")", "{", "MarkupDocBuilder", "descriptionBuilder", "=", "copyMarkupDocBuilder", "(", "markupDocBuilder", ")", ";", "applyPathsDocumentExtension", "(", "new", "PathsDocumentExtension", ".", "Context", "(", "Position", ".", "OPERATION_DESCRIPTION_BEGIN", ",", "descriptionBuilder", ",", "operation", ")", ")", ";", "String", "description", "=", "operation", ".", "getOperation", "(", ")", ".", "getDescription", "(", ")", ";", "if", "(", "isNotBlank", "(", "description", ")", ")", "{", "descriptionBuilder", ".", "paragraph", "(", "markupDescription", "(", "config", ".", "getSwaggerMarkupLanguage", "(", ")", ",", "markupDocBuilder", ",", "description", ")", ")", ";", "}", "applyPathsDocumentExtension", "(", "new", "PathsDocumentExtension", ".", "Context", "(", "Position", ".", "OPERATION_DESCRIPTION_END", ",", "descriptionBuilder", ",", "operation", ")", ")", ";", "String", "descriptionContent", "=", "descriptionBuilder", ".", "toString", "(", ")", ";", "applyPathsDocumentExtension", "(", "new", "PathsDocumentExtension", ".", "Context", "(", "Position", ".", "OPERATION_DESCRIPTION_BEFORE", ",", "markupDocBuilder", ",", "operation", ")", ")", ";", "if", "(", "isNotBlank", "(", "descriptionContent", ")", ")", "{", "buildSectionTitle", "(", "markupDocBuilder", ",", "labels", ".", "getLabel", "(", "DESCRIPTION", ")", ")", ";", "markupDocBuilder", ".", "text", "(", "descriptionContent", ")", ";", "}", "applyPathsDocumentExtension", "(", "new", "PathsDocumentExtension", ".", "Context", "(", "Position", ".", "OPERATION_DESCRIPTION_AFTER", ",", "markupDocBuilder", ",", "operation", ")", ")", ";", "}" ]
Adds a operation description to the document. @param operation the Swagger Operation
[ "Adds", "a", "operation", "description", "to", "the", "document", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java#L172-L188
17,073
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java
PathOperationComponent.buildParametersSection
private List<ObjectType> buildParametersSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { List<ObjectType> inlineDefinitions = new ArrayList<>(); parameterTableComponent.apply(markupDocBuilder, ParameterTableComponent.parameters( operation, inlineDefinitions, getSectionTitleLevel() )); return inlineDefinitions; }
java
private List<ObjectType> buildParametersSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { List<ObjectType> inlineDefinitions = new ArrayList<>(); parameterTableComponent.apply(markupDocBuilder, ParameterTableComponent.parameters( operation, inlineDefinitions, getSectionTitleLevel() )); return inlineDefinitions; }
[ "private", "List", "<", "ObjectType", ">", "buildParametersSection", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "PathOperation", "operation", ")", "{", "List", "<", "ObjectType", ">", "inlineDefinitions", "=", "new", "ArrayList", "<>", "(", ")", ";", "parameterTableComponent", ".", "apply", "(", "markupDocBuilder", ",", "ParameterTableComponent", ".", "parameters", "(", "operation", ",", "inlineDefinitions", ",", "getSectionTitleLevel", "(", ")", ")", ")", ";", "return", "inlineDefinitions", ";", "}" ]
Builds the parameters section @param operation the Swagger Operation
[ "Builds", "the", "parameters", "section" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java#L195-L206
17,074
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java
PathOperationComponent.buildBodyParameterSection
private List<ObjectType> buildBodyParameterSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { List<ObjectType> inlineDefinitions = new ArrayList<>(); bodyParameterComponent.apply(markupDocBuilder, BodyParameterComponent.parameters( operation, inlineDefinitions )); return inlineDefinitions; }
java
private List<ObjectType> buildBodyParameterSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { List<ObjectType> inlineDefinitions = new ArrayList<>(); bodyParameterComponent.apply(markupDocBuilder, BodyParameterComponent.parameters( operation, inlineDefinitions )); return inlineDefinitions; }
[ "private", "List", "<", "ObjectType", ">", "buildBodyParameterSection", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "PathOperation", "operation", ")", "{", "List", "<", "ObjectType", ">", "inlineDefinitions", "=", "new", "ArrayList", "<>", "(", ")", ";", "bodyParameterComponent", ".", "apply", "(", "markupDocBuilder", ",", "BodyParameterComponent", ".", "parameters", "(", "operation", ",", "inlineDefinitions", ")", ")", ";", "return", "inlineDefinitions", ";", "}" ]
Builds the body parameter section @param operation the Swagger Operation @return a list of inlined types.
[ "Builds", "the", "body", "parameter", "section" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java#L214-L223
17,075
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java
PathOperationComponent.buildSectionTitle
private void buildSectionTitle(MarkupDocBuilder markupDocBuilder, String title) { if (config.getPathsGroupedBy() == GroupBy.AS_IS) { markupDocBuilder.sectionTitleLevel3(title); } else { markupDocBuilder.sectionTitleLevel4(title); } }
java
private void buildSectionTitle(MarkupDocBuilder markupDocBuilder, String title) { if (config.getPathsGroupedBy() == GroupBy.AS_IS) { markupDocBuilder.sectionTitleLevel3(title); } else { markupDocBuilder.sectionTitleLevel4(title); } }
[ "private", "void", "buildSectionTitle", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "String", "title", ")", "{", "if", "(", "config", ".", "getPathsGroupedBy", "(", ")", "==", "GroupBy", ".", "AS_IS", ")", "{", "markupDocBuilder", ".", "sectionTitleLevel3", "(", "title", ")", ";", "}", "else", "{", "markupDocBuilder", ".", "sectionTitleLevel4", "(", "title", ")", ";", "}", "}" ]
Adds a operation section title to the document. @param title the section title
[ "Adds", "a", "operation", "section", "title", "to", "the", "document", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/component/PathOperationComponent.java#L242-L248
17,076
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/TagUtils.java
TagUtils.toSortedMap
public static Map<String, Tag> toSortedMap(List<Tag> tags, Comparator<String> comparator) { Map<String, Tag> sortedMap; if (comparator == null) sortedMap = new LinkedHashMap<>(); else sortedMap = new TreeMap<>(comparator); tags.forEach(tag -> sortedMap.put(tag.getName(), tag)); return sortedMap; }
java
public static Map<String, Tag> toSortedMap(List<Tag> tags, Comparator<String> comparator) { Map<String, Tag> sortedMap; if (comparator == null) sortedMap = new LinkedHashMap<>(); else sortedMap = new TreeMap<>(comparator); tags.forEach(tag -> sortedMap.put(tag.getName(), tag)); return sortedMap; }
[ "public", "static", "Map", "<", "String", ",", "Tag", ">", "toSortedMap", "(", "List", "<", "Tag", ">", "tags", ",", "Comparator", "<", "String", ">", "comparator", ")", "{", "Map", "<", "String", ",", "Tag", ">", "sortedMap", ";", "if", "(", "comparator", "==", "null", ")", "sortedMap", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "else", "sortedMap", "=", "new", "TreeMap", "<>", "(", "comparator", ")", ";", "tags", ".", "forEach", "(", "tag", "->", "sortedMap", ".", "put", "(", "tag", ".", "getName", "(", ")", ",", "tag", ")", ")", ";", "return", "sortedMap", ";", "}" ]
Converts the global Tag list into a Map where the tag name is the key and the Tag the value. Either ordered or as-is, if the comparator is null. @param tags the List of tags @param comparator the comparator to use. @return the Map of tags. Either ordered or as-is, if the comparator is null.
[ "Converts", "the", "global", "Tag", "list", "into", "a", "Map", "where", "the", "tag", "name", "is", "the", "key", "and", "the", "Tag", "the", "value", ".", "Either", "ordered", "or", "as", "-", "is", "if", "the", "comparator", "is", "null", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/TagUtils.java#L41-L49
17,077
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/TagUtils.java
TagUtils.groupOperationsByTag
public static Multimap<String, PathOperation> groupOperationsByTag(List<PathOperation> allOperations, Comparator<PathOperation> operationOrdering) { Multimap<String, PathOperation> operationsGroupedByTag; if (operationOrdering == null) { operationsGroupedByTag = LinkedHashMultimap.create(); } else { operationsGroupedByTag = MultimapBuilder.linkedHashKeys().treeSetValues(operationOrdering).build(); } for (PathOperation operation : allOperations) { List<String> tags = operation.getOperation().getTags(); Validate.notEmpty(tags, "Can't GroupBy.TAGS. Operation '%s' has no tags", operation); for (String tag : tags) { if (logger.isDebugEnabled()) { logger.debug("Added path operation '{}' to tag '{}'", operation, tag); } operationsGroupedByTag.put(tag, operation); } } return operationsGroupedByTag; }
java
public static Multimap<String, PathOperation> groupOperationsByTag(List<PathOperation> allOperations, Comparator<PathOperation> operationOrdering) { Multimap<String, PathOperation> operationsGroupedByTag; if (operationOrdering == null) { operationsGroupedByTag = LinkedHashMultimap.create(); } else { operationsGroupedByTag = MultimapBuilder.linkedHashKeys().treeSetValues(operationOrdering).build(); } for (PathOperation operation : allOperations) { List<String> tags = operation.getOperation().getTags(); Validate.notEmpty(tags, "Can't GroupBy.TAGS. Operation '%s' has no tags", operation); for (String tag : tags) { if (logger.isDebugEnabled()) { logger.debug("Added path operation '{}' to tag '{}'", operation, tag); } operationsGroupedByTag.put(tag, operation); } } return operationsGroupedByTag; }
[ "public", "static", "Multimap", "<", "String", ",", "PathOperation", ">", "groupOperationsByTag", "(", "List", "<", "PathOperation", ">", "allOperations", ",", "Comparator", "<", "PathOperation", ">", "operationOrdering", ")", "{", "Multimap", "<", "String", ",", "PathOperation", ">", "operationsGroupedByTag", ";", "if", "(", "operationOrdering", "==", "null", ")", "{", "operationsGroupedByTag", "=", "LinkedHashMultimap", ".", "create", "(", ")", ";", "}", "else", "{", "operationsGroupedByTag", "=", "MultimapBuilder", ".", "linkedHashKeys", "(", ")", ".", "treeSetValues", "(", "operationOrdering", ")", ".", "build", "(", ")", ";", "}", "for", "(", "PathOperation", "operation", ":", "allOperations", ")", "{", "List", "<", "String", ">", "tags", "=", "operation", ".", "getOperation", "(", ")", ".", "getTags", "(", ")", ";", "Validate", ".", "notEmpty", "(", "tags", ",", "\"Can't GroupBy.TAGS. Operation '%s' has no tags\"", ",", "operation", ")", ";", "for", "(", "String", "tag", ":", "tags", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Added path operation '{}' to tag '{}'\"", ",", "operation", ",", "tag", ")", ";", "}", "operationsGroupedByTag", ".", "put", "(", "tag", ",", "operation", ")", ";", "}", "}", "return", "operationsGroupedByTag", ";", "}" ]
Groups the operations by tag. The key of the Multimap is the tag name. The value of the Multimap is a PathOperation @param allOperations all operations @param operationOrdering comparator for operations, for a given tag @return Operations grouped by Tag
[ "Groups", "the", "operations", "by", "tag", ".", "The", "key", "of", "the", "Multimap", "is", "the", "tag", "name", ".", "The", "value", "of", "the", "Multimap", "is", "a", "PathOperation" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/TagUtils.java#L59-L80
17,078
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java
PathsDocument.apply
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, PathsDocument.Parameters params) { Map<String, Path> paths = params.paths; if (MapUtils.isNotEmpty(paths)) { applyPathsDocumentExtension(new Context(Position.DOCUMENT_BEFORE, markupDocBuilder)); buildPathsTitle(markupDocBuilder); applyPathsDocumentExtension(new Context(Position.DOCUMENT_BEGIN, markupDocBuilder)); buildsPathsSection(markupDocBuilder, paths); applyPathsDocumentExtension(new Context(Position.DOCUMENT_END, markupDocBuilder)); applyPathsDocumentExtension(new Context(Position.DOCUMENT_AFTER, markupDocBuilder)); } return markupDocBuilder; }
java
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, PathsDocument.Parameters params) { Map<String, Path> paths = params.paths; if (MapUtils.isNotEmpty(paths)) { applyPathsDocumentExtension(new Context(Position.DOCUMENT_BEFORE, markupDocBuilder)); buildPathsTitle(markupDocBuilder); applyPathsDocumentExtension(new Context(Position.DOCUMENT_BEGIN, markupDocBuilder)); buildsPathsSection(markupDocBuilder, paths); applyPathsDocumentExtension(new Context(Position.DOCUMENT_END, markupDocBuilder)); applyPathsDocumentExtension(new Context(Position.DOCUMENT_AFTER, markupDocBuilder)); } return markupDocBuilder; }
[ "@", "Override", "public", "MarkupDocBuilder", "apply", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "PathsDocument", ".", "Parameters", "params", ")", "{", "Map", "<", "String", ",", "Path", ">", "paths", "=", "params", ".", "paths", ";", "if", "(", "MapUtils", ".", "isNotEmpty", "(", "paths", ")", ")", "{", "applyPathsDocumentExtension", "(", "new", "Context", "(", "Position", ".", "DOCUMENT_BEFORE", ",", "markupDocBuilder", ")", ")", ";", "buildPathsTitle", "(", "markupDocBuilder", ")", ";", "applyPathsDocumentExtension", "(", "new", "Context", "(", "Position", ".", "DOCUMENT_BEGIN", ",", "markupDocBuilder", ")", ")", ";", "buildsPathsSection", "(", "markupDocBuilder", ",", "paths", ")", ";", "applyPathsDocumentExtension", "(", "new", "Context", "(", "Position", ".", "DOCUMENT_END", ",", "markupDocBuilder", ")", ")", ";", "applyPathsDocumentExtension", "(", "new", "Context", "(", "Position", ".", "DOCUMENT_AFTER", ",", "markupDocBuilder", ")", ")", ";", "}", "return", "markupDocBuilder", ";", "}" ]
Builds the paths MarkupDocument. @return the paths MarkupDocument
[ "Builds", "the", "paths", "MarkupDocument", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java#L96-L108
17,079
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java
PathsDocument.buildsPathsSection
private void buildsPathsSection(MarkupDocBuilder markupDocBuilder, Map<String, Path> paths) { List<PathOperation> pathOperations = PathUtils.toPathOperationsList(paths, getHostname(), getBasePath(), config.getOperationOrdering()); if (CollectionUtils.isNotEmpty(pathOperations)) { if (config.getPathsGroupedBy() == GroupBy.AS_IS) { pathOperations.forEach(operation -> buildOperation(markupDocBuilder, operation, config)); } else if (config.getPathsGroupedBy() == GroupBy.TAGS) { Validate.notEmpty(context.getSwagger().getTags(), "Tags must not be empty, when operations are grouped by tags"); // Group operations by tag Multimap<String, PathOperation> operationsGroupedByTag = TagUtils.groupOperationsByTag(pathOperations, config.getOperationOrdering()); Map<String, Tag> tagsMap = TagUtils.toSortedMap(context.getSwagger().getTags(), config.getTagOrdering()); tagsMap.forEach((String tagName, Tag tag) -> { markupDocBuilder.sectionTitleWithAnchorLevel2(WordUtils.capitalize(tagName), tagName + "_resource"); String description = tag.getDescription(); if (StringUtils.isNotBlank(description)) { markupDocBuilder.paragraph(description); } operationsGroupedByTag.get(tagName).forEach(operation -> buildOperation(markupDocBuilder, operation, config)); }); } else if (config.getPathsGroupedBy() == GroupBy.REGEX) { Validate.notNull(config.getHeaderPattern(), "Header regex pattern must not be empty when operations are grouped using regex"); Pattern headerPattern = config.getHeaderPattern(); Multimap<String, PathOperation> operationsGroupedByRegex = RegexUtils.groupOperationsByRegex(pathOperations, headerPattern); Set<String> keys = operationsGroupedByRegex.keySet(); String[] sortedHeaders = RegexUtils.toSortedArray(keys); for (String header : sortedHeaders) { markupDocBuilder.sectionTitleWithAnchorLevel2(WordUtils.capitalize(header), header + "_resource"); operationsGroupedByRegex.get(header).forEach(operation -> buildOperation(markupDocBuilder, operation, config)); } } } }
java
private void buildsPathsSection(MarkupDocBuilder markupDocBuilder, Map<String, Path> paths) { List<PathOperation> pathOperations = PathUtils.toPathOperationsList(paths, getHostname(), getBasePath(), config.getOperationOrdering()); if (CollectionUtils.isNotEmpty(pathOperations)) { if (config.getPathsGroupedBy() == GroupBy.AS_IS) { pathOperations.forEach(operation -> buildOperation(markupDocBuilder, operation, config)); } else if (config.getPathsGroupedBy() == GroupBy.TAGS) { Validate.notEmpty(context.getSwagger().getTags(), "Tags must not be empty, when operations are grouped by tags"); // Group operations by tag Multimap<String, PathOperation> operationsGroupedByTag = TagUtils.groupOperationsByTag(pathOperations, config.getOperationOrdering()); Map<String, Tag> tagsMap = TagUtils.toSortedMap(context.getSwagger().getTags(), config.getTagOrdering()); tagsMap.forEach((String tagName, Tag tag) -> { markupDocBuilder.sectionTitleWithAnchorLevel2(WordUtils.capitalize(tagName), tagName + "_resource"); String description = tag.getDescription(); if (StringUtils.isNotBlank(description)) { markupDocBuilder.paragraph(description); } operationsGroupedByTag.get(tagName).forEach(operation -> buildOperation(markupDocBuilder, operation, config)); }); } else if (config.getPathsGroupedBy() == GroupBy.REGEX) { Validate.notNull(config.getHeaderPattern(), "Header regex pattern must not be empty when operations are grouped using regex"); Pattern headerPattern = config.getHeaderPattern(); Multimap<String, PathOperation> operationsGroupedByRegex = RegexUtils.groupOperationsByRegex(pathOperations, headerPattern); Set<String> keys = operationsGroupedByRegex.keySet(); String[] sortedHeaders = RegexUtils.toSortedArray(keys); for (String header : sortedHeaders) { markupDocBuilder.sectionTitleWithAnchorLevel2(WordUtils.capitalize(header), header + "_resource"); operationsGroupedByRegex.get(header).forEach(operation -> buildOperation(markupDocBuilder, operation, config)); } } } }
[ "private", "void", "buildsPathsSection", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "Map", "<", "String", ",", "Path", ">", "paths", ")", "{", "List", "<", "PathOperation", ">", "pathOperations", "=", "PathUtils", ".", "toPathOperationsList", "(", "paths", ",", "getHostname", "(", ")", ",", "getBasePath", "(", ")", ",", "config", ".", "getOperationOrdering", "(", ")", ")", ";", "if", "(", "CollectionUtils", ".", "isNotEmpty", "(", "pathOperations", ")", ")", "{", "if", "(", "config", ".", "getPathsGroupedBy", "(", ")", "==", "GroupBy", ".", "AS_IS", ")", "{", "pathOperations", ".", "forEach", "(", "operation", "->", "buildOperation", "(", "markupDocBuilder", ",", "operation", ",", "config", ")", ")", ";", "}", "else", "if", "(", "config", ".", "getPathsGroupedBy", "(", ")", "==", "GroupBy", ".", "TAGS", ")", "{", "Validate", ".", "notEmpty", "(", "context", ".", "getSwagger", "(", ")", ".", "getTags", "(", ")", ",", "\"Tags must not be empty, when operations are grouped by tags\"", ")", ";", "// Group operations by tag", "Multimap", "<", "String", ",", "PathOperation", ">", "operationsGroupedByTag", "=", "TagUtils", ".", "groupOperationsByTag", "(", "pathOperations", ",", "config", ".", "getOperationOrdering", "(", ")", ")", ";", "Map", "<", "String", ",", "Tag", ">", "tagsMap", "=", "TagUtils", ".", "toSortedMap", "(", "context", ".", "getSwagger", "(", ")", ".", "getTags", "(", ")", ",", "config", ".", "getTagOrdering", "(", ")", ")", ";", "tagsMap", ".", "forEach", "(", "(", "String", "tagName", ",", "Tag", "tag", ")", "->", "{", "markupDocBuilder", ".", "sectionTitleWithAnchorLevel2", "(", "WordUtils", ".", "capitalize", "(", "tagName", ")", ",", "tagName", "+", "\"_resource\"", ")", ";", "String", "description", "=", "tag", ".", "getDescription", "(", ")", ";", "if", "(", "StringUtils", ".", "isNotBlank", "(", "description", ")", ")", "{", "markupDocBuilder", ".", "paragraph", "(", "description", ")", ";", "}", "operationsGroupedByTag", ".", "get", "(", "tagName", ")", ".", "forEach", "(", "operation", "->", "buildOperation", "(", "markupDocBuilder", ",", "operation", ",", "config", ")", ")", ";", "}", ")", ";", "}", "else", "if", "(", "config", ".", "getPathsGroupedBy", "(", ")", "==", "GroupBy", ".", "REGEX", ")", "{", "Validate", ".", "notNull", "(", "config", ".", "getHeaderPattern", "(", ")", ",", "\"Header regex pattern must not be empty when operations are grouped using regex\"", ")", ";", "Pattern", "headerPattern", "=", "config", ".", "getHeaderPattern", "(", ")", ";", "Multimap", "<", "String", ",", "PathOperation", ">", "operationsGroupedByRegex", "=", "RegexUtils", ".", "groupOperationsByRegex", "(", "pathOperations", ",", "headerPattern", ")", ";", "Set", "<", "String", ">", "keys", "=", "operationsGroupedByRegex", ".", "keySet", "(", ")", ";", "String", "[", "]", "sortedHeaders", "=", "RegexUtils", ".", "toSortedArray", "(", "keys", ")", ";", "for", "(", "String", "header", ":", "sortedHeaders", ")", "{", "markupDocBuilder", ".", "sectionTitleWithAnchorLevel2", "(", "WordUtils", ".", "capitalize", "(", "header", ")", ",", "header", "+", "\"_resource\"", ")", ";", "operationsGroupedByRegex", ".", "get", "(", "header", ")", ".", "forEach", "(", "operation", "->", "buildOperation", "(", "markupDocBuilder", ",", "operation", ",", "config", ")", ")", ";", "}", "}", "}", "}" ]
Builds the paths section. Groups the paths either as-is, by tags or using regex. @param paths the Swagger paths
[ "Builds", "the", "paths", "section", ".", "Groups", "the", "paths", "either", "as", "-", "is", "by", "tags", "or", "using", "regex", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java#L115-L150
17,080
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java
PathsDocument.buildPathsTitle
private void buildPathsTitle(MarkupDocBuilder markupDocBuilder) { if (config.getPathsGroupedBy() == GroupBy.AS_IS) { buildPathsTitle(markupDocBuilder, labels.getLabel(Labels.PATHS)); } else if (config.getPathsGroupedBy() == GroupBy.REGEX) { buildPathsTitle(markupDocBuilder, labels.getLabel(Labels.OPERATIONS)); } else { buildPathsTitle(markupDocBuilder, labels.getLabel(Labels.RESOURCES)); } }
java
private void buildPathsTitle(MarkupDocBuilder markupDocBuilder) { if (config.getPathsGroupedBy() == GroupBy.AS_IS) { buildPathsTitle(markupDocBuilder, labels.getLabel(Labels.PATHS)); } else if (config.getPathsGroupedBy() == GroupBy.REGEX) { buildPathsTitle(markupDocBuilder, labels.getLabel(Labels.OPERATIONS)); } else { buildPathsTitle(markupDocBuilder, labels.getLabel(Labels.RESOURCES)); } }
[ "private", "void", "buildPathsTitle", "(", "MarkupDocBuilder", "markupDocBuilder", ")", "{", "if", "(", "config", ".", "getPathsGroupedBy", "(", ")", "==", "GroupBy", ".", "AS_IS", ")", "{", "buildPathsTitle", "(", "markupDocBuilder", ",", "labels", ".", "getLabel", "(", "Labels", ".", "PATHS", ")", ")", ";", "}", "else", "if", "(", "config", ".", "getPathsGroupedBy", "(", ")", "==", "GroupBy", ".", "REGEX", ")", "{", "buildPathsTitle", "(", "markupDocBuilder", ",", "labels", ".", "getLabel", "(", "Labels", ".", "OPERATIONS", ")", ")", ";", "}", "else", "{", "buildPathsTitle", "(", "markupDocBuilder", ",", "labels", ".", "getLabel", "(", "Labels", ".", "RESOURCES", ")", ")", ";", "}", "}" ]
Builds the path title depending on the operationsGroupedBy configuration setting.
[ "Builds", "the", "path", "title", "depending", "on", "the", "operationsGroupedBy", "configuration", "setting", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java#L155-L163
17,081
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java
PathsDocument.applyPathsDocumentExtension
private void applyPathsDocumentExtension(Context context) { extensionRegistry.getPathsDocumentExtensions().forEach(extension -> extension.apply(context)); }
java
private void applyPathsDocumentExtension(Context context) { extensionRegistry.getPathsDocumentExtensions().forEach(extension -> extension.apply(context)); }
[ "private", "void", "applyPathsDocumentExtension", "(", "Context", "context", ")", "{", "extensionRegistry", ".", "getPathsDocumentExtensions", "(", ")", ".", "forEach", "(", "extension", "->", "extension", ".", "apply", "(", "context", ")", ")", ";", "}" ]
Apply extension context to all OperationsContentExtension. @param context context
[ "Apply", "extension", "context", "to", "all", "OperationsContentExtension", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java#L198-L200
17,082
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java
PathsDocument.buildOperation
private void buildOperation(MarkupDocBuilder markupDocBuilder, PathOperation operation, Swagger2MarkupConfig config) { if (config.isSeparatedOperationsEnabled()) { MarkupDocBuilder pathDocBuilder = copyMarkupDocBuilder(markupDocBuilder); applyPathOperationComponent(pathDocBuilder, operation); java.nio.file.Path operationFile = context.getOutputPath().resolve(operationDocumentNameResolver.apply(operation)); pathDocBuilder.writeToFileWithoutExtension(operationFile, StandardCharsets.UTF_8); if (logger.isDebugEnabled()) { logger.debug("Separate operation file produced : '{}'", operationFile); } buildOperationRef(markupDocBuilder, operation); } else { applyPathOperationComponent(markupDocBuilder, operation); } if (logger.isDebugEnabled()) { logger.debug("Operation processed : '{}' (normalized id = '{}')", operation, normalizeName(operation.getId())); } }
java
private void buildOperation(MarkupDocBuilder markupDocBuilder, PathOperation operation, Swagger2MarkupConfig config) { if (config.isSeparatedOperationsEnabled()) { MarkupDocBuilder pathDocBuilder = copyMarkupDocBuilder(markupDocBuilder); applyPathOperationComponent(pathDocBuilder, operation); java.nio.file.Path operationFile = context.getOutputPath().resolve(operationDocumentNameResolver.apply(operation)); pathDocBuilder.writeToFileWithoutExtension(operationFile, StandardCharsets.UTF_8); if (logger.isDebugEnabled()) { logger.debug("Separate operation file produced : '{}'", operationFile); } buildOperationRef(markupDocBuilder, operation); } else { applyPathOperationComponent(markupDocBuilder, operation); } if (logger.isDebugEnabled()) { logger.debug("Operation processed : '{}' (normalized id = '{}')", operation, normalizeName(operation.getId())); } }
[ "private", "void", "buildOperation", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "PathOperation", "operation", ",", "Swagger2MarkupConfig", "config", ")", "{", "if", "(", "config", ".", "isSeparatedOperationsEnabled", "(", ")", ")", "{", "MarkupDocBuilder", "pathDocBuilder", "=", "copyMarkupDocBuilder", "(", "markupDocBuilder", ")", ";", "applyPathOperationComponent", "(", "pathDocBuilder", ",", "operation", ")", ";", "java", ".", "nio", ".", "file", ".", "Path", "operationFile", "=", "context", ".", "getOutputPath", "(", ")", ".", "resolve", "(", "operationDocumentNameResolver", ".", "apply", "(", "operation", ")", ")", ";", "pathDocBuilder", ".", "writeToFileWithoutExtension", "(", "operationFile", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Separate operation file produced : '{}'\"", ",", "operationFile", ")", ";", "}", "buildOperationRef", "(", "markupDocBuilder", ",", "operation", ")", ";", "}", "else", "{", "applyPathOperationComponent", "(", "markupDocBuilder", ",", "operation", ")", ";", "}", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Operation processed : '{}' (normalized id = '{}')\"", ",", "operation", ",", "normalizeName", "(", "operation", ".", "getId", "(", ")", ")", ")", ";", "}", "}" ]
Builds a path operation depending on generation mode. @param operation operation
[ "Builds", "a", "path", "operation", "depending", "on", "generation", "mode", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java#L207-L225
17,083
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java
PathsDocument.applyPathOperationComponent
private void applyPathOperationComponent(MarkupDocBuilder markupDocBuilder, PathOperation operation) { if (operation != null) { pathOperationComponent.apply(markupDocBuilder, PathOperationComponent.parameters(operation)); } }
java
private void applyPathOperationComponent(MarkupDocBuilder markupDocBuilder, PathOperation operation) { if (operation != null) { pathOperationComponent.apply(markupDocBuilder, PathOperationComponent.parameters(operation)); } }
[ "private", "void", "applyPathOperationComponent", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "PathOperation", "operation", ")", "{", "if", "(", "operation", "!=", "null", ")", "{", "pathOperationComponent", ".", "apply", "(", "markupDocBuilder", ",", "PathOperationComponent", ".", "parameters", "(", "operation", ")", ")", ";", "}", "}" ]
Builds a path operation. @param markupDocBuilder the docbuilder do use for output @param operation the Swagger Operation
[ "Builds", "a", "path", "operation", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java#L233-L237
17,084
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java
PathsDocument.buildOperationRef
private void buildOperationRef(MarkupDocBuilder markupDocBuilder, PathOperation operation) { buildOperationTitle(markupDocBuilder, crossReference(markupDocBuilder, operationDocumentResolverDefault.apply(operation), operation.getId(), operation.getTitle()), "ref-" + operation.getId()); }
java
private void buildOperationRef(MarkupDocBuilder markupDocBuilder, PathOperation operation) { buildOperationTitle(markupDocBuilder, crossReference(markupDocBuilder, operationDocumentResolverDefault.apply(operation), operation.getId(), operation.getTitle()), "ref-" + operation.getId()); }
[ "private", "void", "buildOperationRef", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "PathOperation", "operation", ")", "{", "buildOperationTitle", "(", "markupDocBuilder", ",", "crossReference", "(", "markupDocBuilder", ",", "operationDocumentResolverDefault", ".", "apply", "(", "operation", ")", ",", "operation", ".", "getId", "(", ")", ",", "operation", ".", "getTitle", "(", ")", ")", ",", "\"ref-\"", "+", "operation", ".", "getId", "(", ")", ")", ";", "}" ]
Builds a cross-reference to a separated operation file @param markupDocBuilder the markupDocBuilder do use for output @param operation the Swagger Operation
[ "Builds", "a", "cross", "-", "reference", "to", "a", "separated", "operation", "file" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/PathsDocument.java#L245-L247
17,085
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/RegexUtils.java
RegexUtils.toSortedArray
public static String[] toSortedArray(Set<String> groups) { //TODO: sort in another way than just alphabetically String[] sortedArray = groups.toArray(new String[groups.size()]); Arrays.sort(sortedArray); return sortedArray; }
java
public static String[] toSortedArray(Set<String> groups) { //TODO: sort in another way than just alphabetically String[] sortedArray = groups.toArray(new String[groups.size()]); Arrays.sort(sortedArray); return sortedArray; }
[ "public", "static", "String", "[", "]", "toSortedArray", "(", "Set", "<", "String", ">", "groups", ")", "{", "//TODO: sort in another way than just alphabetically", "String", "[", "]", "sortedArray", "=", "groups", ".", "toArray", "(", "new", "String", "[", "groups", ".", "size", "(", ")", "]", ")", ";", "Arrays", ".", "sort", "(", "sortedArray", ")", ";", "return", "sortedArray", ";", "}" ]
Alphabetically sort the list of groups @param groups List of available groups @return String[] of sorted groups
[ "Alphabetically", "sort", "the", "list", "of", "groups" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/RegexUtils.java#L41-L48
17,086
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/RegexUtils.java
RegexUtils.groupOperationsByRegex
public static Multimap<String, PathOperation> groupOperationsByRegex(List<PathOperation> allOperations, Pattern headerPattern) { Multimap<String, PathOperation> operationsGroupedByRegex = LinkedHashMultimap.create(); for (PathOperation operation : allOperations) { String path = operation.getPath(); Matcher m = headerPattern.matcher(path); if (m.matches() && m.group(1) != null) { if (logger.isDebugEnabled()) { logger.debug("Added path operation '{}' to header '{}'", operation, m.group(1)); } operationsGroupedByRegex.put(m.group(1), operation); } else { if(logger.isWarnEnabled()) { logger.warn("Operation '{}' does not match regex '{}' and will not be included in output", operation, headerPattern.toString()); } } } return operationsGroupedByRegex; }
java
public static Multimap<String, PathOperation> groupOperationsByRegex(List<PathOperation> allOperations, Pattern headerPattern) { Multimap<String, PathOperation> operationsGroupedByRegex = LinkedHashMultimap.create(); for (PathOperation operation : allOperations) { String path = operation.getPath(); Matcher m = headerPattern.matcher(path); if (m.matches() && m.group(1) != null) { if (logger.isDebugEnabled()) { logger.debug("Added path operation '{}' to header '{}'", operation, m.group(1)); } operationsGroupedByRegex.put(m.group(1), operation); } else { if(logger.isWarnEnabled()) { logger.warn("Operation '{}' does not match regex '{}' and will not be included in output", operation, headerPattern.toString()); } } } return operationsGroupedByRegex; }
[ "public", "static", "Multimap", "<", "String", ",", "PathOperation", ">", "groupOperationsByRegex", "(", "List", "<", "PathOperation", ">", "allOperations", ",", "Pattern", "headerPattern", ")", "{", "Multimap", "<", "String", ",", "PathOperation", ">", "operationsGroupedByRegex", "=", "LinkedHashMultimap", ".", "create", "(", ")", ";", "for", "(", "PathOperation", "operation", ":", "allOperations", ")", "{", "String", "path", "=", "operation", ".", "getPath", "(", ")", ";", "Matcher", "m", "=", "headerPattern", ".", "matcher", "(", "path", ")", ";", "if", "(", "m", ".", "matches", "(", ")", "&&", "m", ".", "group", "(", "1", ")", "!=", "null", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Added path operation '{}' to header '{}'\"", ",", "operation", ",", "m", ".", "group", "(", "1", ")", ")", ";", "}", "operationsGroupedByRegex", ".", "put", "(", "m", ".", "group", "(", "1", ")", ",", "operation", ")", ";", "}", "else", "{", "if", "(", "logger", ".", "isWarnEnabled", "(", ")", ")", "{", "logger", ".", "warn", "(", "\"Operation '{}' does not match regex '{}' and will not be included in output\"", ",", "operation", ",", "headerPattern", ".", "toString", "(", ")", ")", ";", "}", "}", "}", "return", "operationsGroupedByRegex", ";", "}" ]
Groups the operations by regex group. The key of the Multimap is the group name. The value of the Multimap is a PathOperation @param allOperations all operations @param headerPattern regex pattern used for determining headers @return Operations grouped by regex
[ "Groups", "the", "operations", "by", "regex", "group", ".", "The", "key", "of", "the", "Multimap", "is", "the", "group", "name", ".", "The", "value", "of", "the", "Multimap", "is", "a", "PathOperation" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/RegexUtils.java#L58-L80
17,087
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/SecurityDocument.java
SecurityDocument.apply
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, SecurityDocument.Parameters params) { Map<String, SecuritySchemeDefinition> definitions = params.securitySchemeDefinitions; if (MapUtils.isNotEmpty(definitions)) { applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEFORE, markupDocBuilder)); buildSecurityTitle(markupDocBuilder, labels.getLabel(SECURITY)); applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEGIN, markupDocBuilder)); buildSecuritySchemeDefinitionsSection(markupDocBuilder, definitions); applySecurityDocumentExtension(new Context(Position.DOCUMENT_END, markupDocBuilder)); applySecurityDocumentExtension(new Context(Position.DOCUMENT_AFTER, markupDocBuilder)); } return markupDocBuilder; }
java
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, SecurityDocument.Parameters params) { Map<String, SecuritySchemeDefinition> definitions = params.securitySchemeDefinitions; if (MapUtils.isNotEmpty(definitions)) { applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEFORE, markupDocBuilder)); buildSecurityTitle(markupDocBuilder, labels.getLabel(SECURITY)); applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEGIN, markupDocBuilder)); buildSecuritySchemeDefinitionsSection(markupDocBuilder, definitions); applySecurityDocumentExtension(new Context(Position.DOCUMENT_END, markupDocBuilder)); applySecurityDocumentExtension(new Context(Position.DOCUMENT_AFTER, markupDocBuilder)); } return markupDocBuilder; }
[ "@", "Override", "public", "MarkupDocBuilder", "apply", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "SecurityDocument", ".", "Parameters", "params", ")", "{", "Map", "<", "String", ",", "SecuritySchemeDefinition", ">", "definitions", "=", "params", ".", "securitySchemeDefinitions", ";", "if", "(", "MapUtils", ".", "isNotEmpty", "(", "definitions", ")", ")", "{", "applySecurityDocumentExtension", "(", "new", "Context", "(", "Position", ".", "DOCUMENT_BEFORE", ",", "markupDocBuilder", ")", ")", ";", "buildSecurityTitle", "(", "markupDocBuilder", ",", "labels", ".", "getLabel", "(", "SECURITY", ")", ")", ";", "applySecurityDocumentExtension", "(", "new", "Context", "(", "Position", ".", "DOCUMENT_BEGIN", ",", "markupDocBuilder", ")", ")", ";", "buildSecuritySchemeDefinitionsSection", "(", "markupDocBuilder", ",", "definitions", ")", ";", "applySecurityDocumentExtension", "(", "new", "Context", "(", "Position", ".", "DOCUMENT_END", ",", "markupDocBuilder", ")", ")", ";", "applySecurityDocumentExtension", "(", "new", "Context", "(", "Position", ".", "DOCUMENT_AFTER", ",", "markupDocBuilder", ")", ")", ";", "}", "return", "markupDocBuilder", ";", "}" ]
Builds the security MarkupDocument. @return the security MarkupDocument
[ "Builds", "the", "security", "MarkupDocument", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/SecurityDocument.java#L54-L66
17,088
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/SecurityDocument.java
SecurityDocument.applySecurityDocumentExtension
private void applySecurityDocumentExtension(Context context) { extensionRegistry.getSecurityDocumentExtensions().forEach(extension -> extension.apply(context)); }
java
private void applySecurityDocumentExtension(Context context) { extensionRegistry.getSecurityDocumentExtensions().forEach(extension -> extension.apply(context)); }
[ "private", "void", "applySecurityDocumentExtension", "(", "Context", "context", ")", "{", "extensionRegistry", ".", "getSecurityDocumentExtensions", "(", ")", ".", "forEach", "(", "extension", "->", "extension", ".", "apply", "(", "context", ")", ")", ";", "}" ]
Apply extension context to all SecurityContentExtension @param context context
[ "Apply", "extension", "context", "to", "all", "SecurityContentExtension" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/SecurityDocument.java#L85-L87
17,089
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/utils/URIUtils.java
URIUtils.uriParent
public static URI uriParent(URI uri) { return uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve("."); }
java
public static URI uriParent(URI uri) { return uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve("."); }
[ "public", "static", "URI", "uriParent", "(", "URI", "uri", ")", "{", "return", "uri", ".", "getPath", "(", ")", ".", "endsWith", "(", "\"/\"", ")", "?", "uri", ".", "resolve", "(", "\"..\"", ")", ":", "uri", ".", "resolve", "(", "\".\"", ")", ";", "}" ]
Return URI parent @param uri source URI @return URI parent
[ "Return", "URI", "parent" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/utils/URIUtils.java#L30-L32
17,090
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/utils/URIUtils.java
URIUtils.convertUriWithoutSchemeToFileScheme
public static URI convertUriWithoutSchemeToFileScheme(URI uri) { if (uri.getScheme() == null) { return Paths.get(uri.getPath()).toUri(); } return uri; }
java
public static URI convertUriWithoutSchemeToFileScheme(URI uri) { if (uri.getScheme() == null) { return Paths.get(uri.getPath()).toUri(); } return uri; }
[ "public", "static", "URI", "convertUriWithoutSchemeToFileScheme", "(", "URI", "uri", ")", "{", "if", "(", "uri", ".", "getScheme", "(", ")", "==", "null", ")", "{", "return", "Paths", ".", "get", "(", "uri", ".", "getPath", "(", ")", ")", ".", "toUri", "(", ")", ";", "}", "return", "uri", ";", "}" ]
Convert an URI without a scheme to a file scheme. @param uri the source URI @return the converted URI
[ "Convert", "an", "URI", "without", "a", "scheme", "to", "a", "file", "scheme", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/utils/URIUtils.java#L40-L45
17,091
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/utils/URIUtils.java
URIUtils.create
public static URI create(String input) { if (isFile(input) || isURL(input)) { return URI.create(input); } else { return Paths.get(input).toUri(); } }
java
public static URI create(String input) { if (isFile(input) || isURL(input)) { return URI.create(input); } else { return Paths.get(input).toUri(); } }
[ "public", "static", "URI", "create", "(", "String", "input", ")", "{", "if", "(", "isFile", "(", "input", ")", "||", "isURL", "(", "input", ")", ")", "{", "return", "URI", ".", "create", "(", "input", ")", ";", "}", "else", "{", "return", "Paths", ".", "get", "(", "input", ")", ".", "toUri", "(", ")", ";", "}", "}" ]
Creates a URI from a String representation of a URI or a Path. @param input String representation of a URI or a Path. @return the URI
[ "Creates", "a", "URI", "from", "a", "String", "representation", "of", "a", "URI", "or", "a", "Path", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/utils/URIUtils.java#L53-L59
17,092
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java
Swagger2MarkupConverter.from
public static Builder from(URI swaggerUri) { Validate.notNull(swaggerUri, "swaggerUri must not be null"); String scheme = swaggerUri.getScheme(); if (scheme != null && swaggerUri.getScheme().startsWith("http")) { try { return from(swaggerUri.toURL()); } catch (MalformedURLException e) { throw new RuntimeException("Failed to convert URI to URL", e); } } else if (scheme != null && swaggerUri.getScheme().startsWith("file")) { return from(Paths.get(swaggerUri)); } else { return from(URIUtils.convertUriWithoutSchemeToFileScheme(swaggerUri)); } }
java
public static Builder from(URI swaggerUri) { Validate.notNull(swaggerUri, "swaggerUri must not be null"); String scheme = swaggerUri.getScheme(); if (scheme != null && swaggerUri.getScheme().startsWith("http")) { try { return from(swaggerUri.toURL()); } catch (MalformedURLException e) { throw new RuntimeException("Failed to convert URI to URL", e); } } else if (scheme != null && swaggerUri.getScheme().startsWith("file")) { return from(Paths.get(swaggerUri)); } else { return from(URIUtils.convertUriWithoutSchemeToFileScheme(swaggerUri)); } }
[ "public", "static", "Builder", "from", "(", "URI", "swaggerUri", ")", "{", "Validate", ".", "notNull", "(", "swaggerUri", ",", "\"swaggerUri must not be null\"", ")", ";", "String", "scheme", "=", "swaggerUri", ".", "getScheme", "(", ")", ";", "if", "(", "scheme", "!=", "null", "&&", "swaggerUri", ".", "getScheme", "(", ")", ".", "startsWith", "(", "\"http\"", ")", ")", "{", "try", "{", "return", "from", "(", "swaggerUri", ".", "toURL", "(", ")", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to convert URI to URL\"", ",", "e", ")", ";", "}", "}", "else", "if", "(", "scheme", "!=", "null", "&&", "swaggerUri", ".", "getScheme", "(", ")", ".", "startsWith", "(", "\"file\"", ")", ")", "{", "return", "from", "(", "Paths", ".", "get", "(", "swaggerUri", ")", ")", ";", "}", "else", "{", "return", "from", "(", "URIUtils", ".", "convertUriWithoutSchemeToFileScheme", "(", "swaggerUri", ")", ")", ";", "}", "}" ]
Creates a Swagger2MarkupConverter.Builder from a URI. @param swaggerUri the URI @return a Swagger2MarkupConverter
[ "Creates", "a", "Swagger2MarkupConverter", ".", "Builder", "from", "a", "URI", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java#L71-L85
17,093
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java
Swagger2MarkupConverter.from
public static Builder from(Path swaggerPath) { Validate.notNull(swaggerPath, "swaggerPath must not be null"); if (Files.notExists(swaggerPath)) { throw new IllegalArgumentException(String.format("swaggerPath does not exist: %s", swaggerPath)); } try { if (Files.isHidden(swaggerPath)) { throw new IllegalArgumentException("swaggerPath must not be a hidden file"); } } catch (IOException e) { throw new RuntimeException("Failed to check if swaggerPath is a hidden file", e); } return new Builder(swaggerPath); }
java
public static Builder from(Path swaggerPath) { Validate.notNull(swaggerPath, "swaggerPath must not be null"); if (Files.notExists(swaggerPath)) { throw new IllegalArgumentException(String.format("swaggerPath does not exist: %s", swaggerPath)); } try { if (Files.isHidden(swaggerPath)) { throw new IllegalArgumentException("swaggerPath must not be a hidden file"); } } catch (IOException e) { throw new RuntimeException("Failed to check if swaggerPath is a hidden file", e); } return new Builder(swaggerPath); }
[ "public", "static", "Builder", "from", "(", "Path", "swaggerPath", ")", "{", "Validate", ".", "notNull", "(", "swaggerPath", ",", "\"swaggerPath must not be null\"", ")", ";", "if", "(", "Files", ".", "notExists", "(", "swaggerPath", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"swaggerPath does not exist: %s\"", ",", "swaggerPath", ")", ")", ";", "}", "try", "{", "if", "(", "Files", ".", "isHidden", "(", "swaggerPath", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"swaggerPath must not be a hidden file\"", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to check if swaggerPath is a hidden file\"", ",", "e", ")", ";", "}", "return", "new", "Builder", "(", "swaggerPath", ")", ";", "}" ]
Creates a Swagger2MarkupConverter.Builder using a local Path. @param swaggerPath the local Path @return a Swagger2MarkupConverter
[ "Creates", "a", "Swagger2MarkupConverter", ".", "Builder", "using", "a", "local", "Path", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java#L104-L117
17,094
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java
Swagger2MarkupConverter.from
public static Builder from(String swaggerString) { Validate.notEmpty(swaggerString, "swaggerString must not be null"); return from(new StringReader(swaggerString)); }
java
public static Builder from(String swaggerString) { Validate.notEmpty(swaggerString, "swaggerString must not be null"); return from(new StringReader(swaggerString)); }
[ "public", "static", "Builder", "from", "(", "String", "swaggerString", ")", "{", "Validate", ".", "notEmpty", "(", "swaggerString", ",", "\"swaggerString must not be null\"", ")", ";", "return", "from", "(", "new", "StringReader", "(", "swaggerString", ")", ")", ";", "}" ]
Creates a Swagger2MarkupConverter.Builder from a given Swagger YAML or JSON String. @param swaggerString the Swagger YAML or JSON String. @return a Swagger2MarkupConverter
[ "Creates", "a", "Swagger2MarkupConverter", ".", "Builder", "from", "a", "given", "Swagger", "YAML", "or", "JSON", "String", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java#L136-L139
17,095
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java
Swagger2MarkupConverter.from
public static Builder from(Reader swaggerReader) { Validate.notNull(swaggerReader, "swaggerReader must not be null"); Swagger swagger; try { swagger = new SwaggerParser().parse(IOUtils.toString(swaggerReader)); } catch (IOException e) { throw new RuntimeException("Swagger source can not be parsed", e); } if (swagger == null) throw new IllegalArgumentException("Swagger source is in a wrong format"); return new Builder(swagger); }
java
public static Builder from(Reader swaggerReader) { Validate.notNull(swaggerReader, "swaggerReader must not be null"); Swagger swagger; try { swagger = new SwaggerParser().parse(IOUtils.toString(swaggerReader)); } catch (IOException e) { throw new RuntimeException("Swagger source can not be parsed", e); } if (swagger == null) throw new IllegalArgumentException("Swagger source is in a wrong format"); return new Builder(swagger); }
[ "public", "static", "Builder", "from", "(", "Reader", "swaggerReader", ")", "{", "Validate", ".", "notNull", "(", "swaggerReader", ",", "\"swaggerReader must not be null\"", ")", ";", "Swagger", "swagger", ";", "try", "{", "swagger", "=", "new", "SwaggerParser", "(", ")", ".", "parse", "(", "IOUtils", ".", "toString", "(", "swaggerReader", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Swagger source can not be parsed\"", ",", "e", ")", ";", "}", "if", "(", "swagger", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Swagger source is in a wrong format\"", ")", ";", "return", "new", "Builder", "(", "swagger", ")", ";", "}" ]
Creates a Swagger2MarkupConverter.Builder from a given Swagger YAML or JSON reader. @param swaggerReader the Swagger YAML or JSON reader. @return a Swagger2MarkupConverter
[ "Creates", "a", "Swagger2MarkupConverter", ".", "Builder", "from", "a", "given", "Swagger", "YAML", "or", "JSON", "reader", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java#L147-L159
17,096
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java
ExamplesUtil.generateResponseExampleMap
public static Map<String, Object> generateResponseExampleMap(boolean generateMissingExamples, PathOperation operation, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder) { Map<String, Object> examples = new LinkedHashMap<>(); Map<String, Response> responses = operation.getOperation().getResponses(); if (responses != null) for (Map.Entry<String, Response> responseEntry : responses.entrySet()) { Response response = responseEntry.getValue(); Object example = response.getExamples(); if (example == null) { Model model = response.getResponseSchema(); if (model != null) { Property schema = new PropertyModelConverter().modelToProperty(model); if (schema != null) { example = schema.getExample(); if (example == null && schema instanceof RefProperty) { String simpleRef = ((RefProperty) schema).getSimpleRef(); example = generateExampleForRefModel(generateMissingExamples, simpleRef, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>()); } if (example == null && schema instanceof ArrayProperty && generateMissingExamples) { example = generateExampleForArrayProperty((ArrayProperty) schema, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>()); } if (example == null && schema instanceof ObjectProperty && generateMissingExamples) { example = exampleMapForProperties(((ObjectProperty) schema).getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>()); } if (example == null && generateMissingExamples) { example = PropertyAdapter.generateExample(schema, markupDocBuilder); } } } } if (example != null) examples.put(responseEntry.getKey(), example); } return examples; }
java
public static Map<String, Object> generateResponseExampleMap(boolean generateMissingExamples, PathOperation operation, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder) { Map<String, Object> examples = new LinkedHashMap<>(); Map<String, Response> responses = operation.getOperation().getResponses(); if (responses != null) for (Map.Entry<String, Response> responseEntry : responses.entrySet()) { Response response = responseEntry.getValue(); Object example = response.getExamples(); if (example == null) { Model model = response.getResponseSchema(); if (model != null) { Property schema = new PropertyModelConverter().modelToProperty(model); if (schema != null) { example = schema.getExample(); if (example == null && schema instanceof RefProperty) { String simpleRef = ((RefProperty) schema).getSimpleRef(); example = generateExampleForRefModel(generateMissingExamples, simpleRef, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>()); } if (example == null && schema instanceof ArrayProperty && generateMissingExamples) { example = generateExampleForArrayProperty((ArrayProperty) schema, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>()); } if (example == null && schema instanceof ObjectProperty && generateMissingExamples) { example = exampleMapForProperties(((ObjectProperty) schema).getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>()); } if (example == null && generateMissingExamples) { example = PropertyAdapter.generateExample(schema, markupDocBuilder); } } } } if (example != null) examples.put(responseEntry.getKey(), example); } return examples; }
[ "public", "static", "Map", "<", "String", ",", "Object", ">", "generateResponseExampleMap", "(", "boolean", "generateMissingExamples", ",", "PathOperation", "operation", ",", "Map", "<", "String", ",", "Model", ">", "definitions", ",", "DocumentResolver", "definitionDocumentResolver", ",", "MarkupDocBuilder", "markupDocBuilder", ")", "{", "Map", "<", "String", ",", "Object", ">", "examples", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "Map", "<", "String", ",", "Response", ">", "responses", "=", "operation", ".", "getOperation", "(", ")", ".", "getResponses", "(", ")", ";", "if", "(", "responses", "!=", "null", ")", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Response", ">", "responseEntry", ":", "responses", ".", "entrySet", "(", ")", ")", "{", "Response", "response", "=", "responseEntry", ".", "getValue", "(", ")", ";", "Object", "example", "=", "response", ".", "getExamples", "(", ")", ";", "if", "(", "example", "==", "null", ")", "{", "Model", "model", "=", "response", ".", "getResponseSchema", "(", ")", ";", "if", "(", "model", "!=", "null", ")", "{", "Property", "schema", "=", "new", "PropertyModelConverter", "(", ")", ".", "modelToProperty", "(", "model", ")", ";", "if", "(", "schema", "!=", "null", ")", "{", "example", "=", "schema", ".", "getExample", "(", ")", ";", "if", "(", "example", "==", "null", "&&", "schema", "instanceof", "RefProperty", ")", "{", "String", "simpleRef", "=", "(", "(", "RefProperty", ")", "schema", ")", ".", "getSimpleRef", "(", ")", ";", "example", "=", "generateExampleForRefModel", "(", "generateMissingExamples", ",", "simpleRef", ",", "definitions", ",", "definitionDocumentResolver", ",", "markupDocBuilder", ",", "new", "HashMap", "<>", "(", ")", ")", ";", "}", "if", "(", "example", "==", "null", "&&", "schema", "instanceof", "ArrayProperty", "&&", "generateMissingExamples", ")", "{", "example", "=", "generateExampleForArrayProperty", "(", "(", "ArrayProperty", ")", "schema", ",", "definitions", ",", "definitionDocumentResolver", ",", "markupDocBuilder", ",", "new", "HashMap", "<>", "(", ")", ")", ";", "}", "if", "(", "example", "==", "null", "&&", "schema", "instanceof", "ObjectProperty", "&&", "generateMissingExamples", ")", "{", "example", "=", "exampleMapForProperties", "(", "(", "(", "ObjectProperty", ")", "schema", ")", ".", "getProperties", "(", ")", ",", "definitions", ",", "definitionDocumentResolver", ",", "markupDocBuilder", ",", "new", "HashMap", "<>", "(", ")", ")", ";", "}", "if", "(", "example", "==", "null", "&&", "generateMissingExamples", ")", "{", "example", "=", "PropertyAdapter", ".", "generateExample", "(", "schema", ",", "markupDocBuilder", ")", ";", "}", "}", "}", "}", "if", "(", "example", "!=", "null", ")", "examples", ".", "put", "(", "responseEntry", ".", "getKey", "(", ")", ",", "example", ")", ";", "}", "return", "examples", ";", "}" ]
Generates a Map of response examples @param generateMissingExamples specifies the missing examples should be generated @param operation the Swagger Operation @param definitions the map of definitions @param markupDocBuilder the markup builder @return map containing response examples.
[ "Generates", "a", "Map", "of", "response", "examples" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java#L50-L87
17,097
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java
ExamplesUtil.getExamplesFromBodyParameter
private static Object getExamplesFromBodyParameter(Parameter parameter) { Object examples = ((BodyParameter) parameter).getExamples(); if (examples == null) { examples = parameter.getVendorExtensions().get("x-examples"); } return examples; }
java
private static Object getExamplesFromBodyParameter(Parameter parameter) { Object examples = ((BodyParameter) parameter).getExamples(); if (examples == null) { examples = parameter.getVendorExtensions().get("x-examples"); } return examples; }
[ "private", "static", "Object", "getExamplesFromBodyParameter", "(", "Parameter", "parameter", ")", "{", "Object", "examples", "=", "(", "(", "BodyParameter", ")", "parameter", ")", ".", "getExamples", "(", ")", ";", "if", "(", "examples", "==", "null", ")", "{", "examples", "=", "parameter", ".", "getVendorExtensions", "(", ")", ".", "get", "(", "\"x-examples\"", ")", ";", "}", "return", "examples", ";", "}" ]
Retrieves example payloads for body parameter either from examples or from vendor extensions. @param parameter parameter to get the examples for @return examples if found otherwise null
[ "Retrieves", "example", "payloads", "for", "body", "parameter", "either", "from", "examples", "or", "from", "vendor", "extensions", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java#L183-L189
17,098
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java
ExamplesUtil.encodeExampleForUrl
private static String encodeExampleForUrl(Object example) { try { return URLEncoder.encode(String.valueOf(example), "UTF-8"); } catch (UnsupportedEncodingException exception) { throw new RuntimeException(exception); } }
java
private static String encodeExampleForUrl(Object example) { try { return URLEncoder.encode(String.valueOf(example), "UTF-8"); } catch (UnsupportedEncodingException exception) { throw new RuntimeException(exception); } }
[ "private", "static", "String", "encodeExampleForUrl", "(", "Object", "example", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "String", ".", "valueOf", "(", "example", ")", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "exception", ")", "{", "throw", "new", "RuntimeException", "(", "exception", ")", ";", "}", "}" ]
Encodes an example value for use in an URL @param example the example value @return encoded example value
[ "Encodes", "an", "example", "value", "for", "use", "in", "an", "URL" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java#L197-L203
17,099
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java
ExamplesUtil.generateExampleForRefModel
private static Object generateExampleForRefModel(boolean generateMissingExamples, String simpleRef, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) { Model model = definitions.get(simpleRef); Object example = null; if (model != null) { example = model.getExample(); if (example == null && generateMissingExamples) { if (!refStack.containsKey(simpleRef)) { refStack.put(simpleRef, 1); } else { refStack.put(simpleRef, refStack.get(simpleRef) + 1); } if (refStack.get(simpleRef) <= MAX_RECURSION_TO_DISPLAY) { if (model instanceof ComposedModel) { //FIXME: getProperties() may throw NullPointerException example = exampleMapForProperties(((ObjectType) ModelUtils.getType(model, definitions, definitionDocumentResolver)).getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>()); } else { example = exampleMapForProperties(model.getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, refStack); } } else { return "..."; } refStack.put(simpleRef, refStack.get(simpleRef) - 1); } } return example; }
java
private static Object generateExampleForRefModel(boolean generateMissingExamples, String simpleRef, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) { Model model = definitions.get(simpleRef); Object example = null; if (model != null) { example = model.getExample(); if (example == null && generateMissingExamples) { if (!refStack.containsKey(simpleRef)) { refStack.put(simpleRef, 1); } else { refStack.put(simpleRef, refStack.get(simpleRef) + 1); } if (refStack.get(simpleRef) <= MAX_RECURSION_TO_DISPLAY) { if (model instanceof ComposedModel) { //FIXME: getProperties() may throw NullPointerException example = exampleMapForProperties(((ObjectType) ModelUtils.getType(model, definitions, definitionDocumentResolver)).getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>()); } else { example = exampleMapForProperties(model.getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, refStack); } } else { return "..."; } refStack.put(simpleRef, refStack.get(simpleRef) - 1); } } return example; }
[ "private", "static", "Object", "generateExampleForRefModel", "(", "boolean", "generateMissingExamples", ",", "String", "simpleRef", ",", "Map", "<", "String", ",", "Model", ">", "definitions", ",", "DocumentResolver", "definitionDocumentResolver", ",", "MarkupDocBuilder", "markupDocBuilder", ",", "Map", "<", "String", ",", "Integer", ">", "refStack", ")", "{", "Model", "model", "=", "definitions", ".", "get", "(", "simpleRef", ")", ";", "Object", "example", "=", "null", ";", "if", "(", "model", "!=", "null", ")", "{", "example", "=", "model", ".", "getExample", "(", ")", ";", "if", "(", "example", "==", "null", "&&", "generateMissingExamples", ")", "{", "if", "(", "!", "refStack", ".", "containsKey", "(", "simpleRef", ")", ")", "{", "refStack", ".", "put", "(", "simpleRef", ",", "1", ")", ";", "}", "else", "{", "refStack", ".", "put", "(", "simpleRef", ",", "refStack", ".", "get", "(", "simpleRef", ")", "+", "1", ")", ";", "}", "if", "(", "refStack", ".", "get", "(", "simpleRef", ")", "<=", "MAX_RECURSION_TO_DISPLAY", ")", "{", "if", "(", "model", "instanceof", "ComposedModel", ")", "{", "//FIXME: getProperties() may throw NullPointerException", "example", "=", "exampleMapForProperties", "(", "(", "(", "ObjectType", ")", "ModelUtils", ".", "getType", "(", "model", ",", "definitions", ",", "definitionDocumentResolver", ")", ")", ".", "getProperties", "(", ")", ",", "definitions", ",", "definitionDocumentResolver", ",", "markupDocBuilder", ",", "new", "HashMap", "<>", "(", ")", ")", ";", "}", "else", "{", "example", "=", "exampleMapForProperties", "(", "model", ".", "getProperties", "(", ")", ",", "definitions", ",", "definitionDocumentResolver", ",", "markupDocBuilder", ",", "refStack", ")", ";", "}", "}", "else", "{", "return", "\"...\"", ";", "}", "refStack", ".", "put", "(", "simpleRef", ",", "refStack", ".", "get", "(", "simpleRef", ")", "-", "1", ")", ";", "}", "}", "return", "example", ";", "}" ]
Generates an example object from a simple reference @param generateMissingExamples specifies the missing examples should be generated @param simpleRef the simple reference string @param definitions the map of definitions @param markupDocBuilder the markup builder @param refStack map to detect cyclic references @return returns an Object or Map of examples
[ "Generates", "an", "example", "object", "from", "a", "simple", "reference" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java#L215-L240