target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testUrl() throws InterruptedException, IOException, ApiException { wireMockRule.stubFor( get(urlPathEqualTo("/version/")) .willReturn( aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBody("{}"))); Version versionUtil = new Version(client); try { VersionInfo versionInfo = versionUtil.getVersion(); } catch (ApiException ex) { } verify( getRequestedFor(urlPathEqualTo("/version/")) .withHeader("Content-Type", equalTo("application/json")) .withHeader("Accept", equalTo("application/json"))); }
|
public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); }
|
Version { public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); } }
|
Version { public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); } Version(); Version(ApiClient apiClient); }
|
Version { public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); } Version(); Version(ApiClient apiClient); VersionInfo getVersion(); }
|
Version { public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); } Version(); Version(ApiClient apiClient); VersionInfo getVersion(); }
|
@Test public void testFailure() throws InterruptedException, IOException, ApiException { wireMockRule.stubFor( get(urlPathEqualTo("/version/")) .willReturn( aResponse() .withStatus(401) .withHeader("Content-Type", "application/json") .withBody("{}"))); Version versionUtil = new Version(client); boolean thrown = false; try { VersionInfo versionInfo = versionUtil.getVersion(); } catch (ApiException ex) { assertEquals(401, ex.getCode()); thrown = true; } assertEquals(thrown, true); verify( getRequestedFor(urlPathEqualTo("/version/")) .withHeader("Content-Type", equalTo("application/json")) .withHeader("Accept", equalTo("application/json"))); }
|
public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); }
|
Version { public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); } }
|
Version { public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); } Version(); Version(ApiClient apiClient); }
|
Version { public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); } Version(); Version(ApiClient apiClient); VersionInfo getVersion(); }
|
Version { public VersionInfo getVersion() throws ApiException, IOException { Call call = versionApi.getCodeCall(null); Response response = null; try { response = call.execute(); } catch (IOException e) { throw new ApiException(e); } if (!response.isSuccessful()) { throw new ApiException(response.code(), "Version request failed: " + response.code()); } return this.versionApi .getApiClient() .getJSON() .deserialize(response.body().string(), VersionInfo.class); } Version(); Version(ApiClient apiClient); VersionInfo getVersion(); }
|
@Test public void testUrl() throws IOException, ApiException, InterruptedException { PortForward forward = new PortForward(client); V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name(podName).namespace(namespace)); wireMockRule.stubFor( get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/portforward")) .willReturn( aResponse() .withStatus(404) .withHeader("Content-Type", "application/json") .withBody("{}"))); int portNumber = 8080; List<Integer> ports = new ArrayList<>(); ports.add(portNumber); assertThrows( ApiException.class, () -> { forward.forward(pod, ports); }); Thread.sleep(2000); wireMockRule.verify( getRequestedFor( urlPathEqualTo( "/api/v1/namespaces/" + namespace + "/pods/" + podName + "/portforward")) .withQueryParam("ports", equalTo(Integer.toString(portNumber)))); }
|
public PortForwardResult forward(V1Pod pod, List<Integer> ports) throws ApiException, IOException { return forward(pod.getMetadata().getNamespace(), pod.getMetadata().getName(), ports); }
|
PortForward { public PortForwardResult forward(V1Pod pod, List<Integer> ports) throws ApiException, IOException { return forward(pod.getMetadata().getNamespace(), pod.getMetadata().getName(), ports); } }
|
PortForward { public PortForwardResult forward(V1Pod pod, List<Integer> ports) throws ApiException, IOException { return forward(pod.getMetadata().getNamespace(), pod.getMetadata().getName(), ports); } PortForward(); PortForward(ApiClient apiClient); }
|
PortForward { public PortForwardResult forward(V1Pod pod, List<Integer> ports) throws ApiException, IOException { return forward(pod.getMetadata().getNamespace(), pod.getMetadata().getName(), ports); } PortForward(); PortForward(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); PortForwardResult forward(V1Pod pod, List<Integer> ports); PortForwardResult forward(String namespace, String name, List<Integer> ports); }
|
PortForward { public PortForwardResult forward(V1Pod pod, List<Integer> ports) throws ApiException, IOException { return forward(pod.getMetadata().getNamespace(), pod.getMetadata().getName(), ports); } PortForward(); PortForward(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); PortForwardResult forward(V1Pod pod, List<Integer> ports); PortForwardResult forward(String namespace, String name, List<Integer> ports); }
|
@Test public void testIncompleteData1() { InputStream inputStream = new ByteArrayInputStream(BAD_OUTPUT_INCOMPLETE_MSG1.getBytes(StandardCharsets.UTF_8)); int exitCode = Exec.parseExitCode(client, inputStream); assertEquals(-1, exitCode); }
|
static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; }
|
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; } }
|
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; } Exec(); Exec(ApiClient apiClient); }
|
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; } Exec(); Exec(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); ExecutionBuilder newExecutionBuilder(String namespace, String name, String[] command); Process exec(String namespace, String name, String[] command, boolean stdin); Process exec(V1Pod pod, String[] command, boolean stdin); Process exec(String namespace, String name, String[] command, boolean stdin, boolean tty); Process exec(V1Pod pod, String[] command, boolean stdin, boolean tty); Process exec(V1Pod pod, String[] command, String container, boolean stdin, boolean tty); Process exec(
String namespace, String name, String[] command, String container, boolean stdin, boolean tty); }
|
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; } Exec(); Exec(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); ExecutionBuilder newExecutionBuilder(String namespace, String name, String[] command); Process exec(String namespace, String name, String[] command, boolean stdin); Process exec(V1Pod pod, String[] command, boolean stdin); Process exec(String namespace, String name, String[] command, boolean stdin, boolean tty); Process exec(V1Pod pod, String[] command, boolean stdin, boolean tty); Process exec(V1Pod pod, String[] command, String container, boolean stdin, boolean tty); Process exec(
String namespace, String name, String[] command, String container, boolean stdin, boolean tty); }
|
@Test public void testGroupResourcesByName() { Discovery discovery = new Discovery(apiClient); Set<Discovery.APIResource> discoveredResources = discovery.groupResourcesByName( "foo", Arrays.asList("v1", "v2"), "v1", new V1APIResourceList() .resources( Arrays.asList( new V1APIResource() .name("meows") .kind("Meow") .namespaced(true) .singularName("meow"), new V1APIResource() .name("meows/mouse") .kind("MeowMouse") .namespaced(true) .singularName(""), new V1APIResource() .name("zigs") .kind("Zig") .namespaced(false) .singularName("zig")))); assertEquals(2, discoveredResources.size()); Discovery.APIResource meow = discoveredResources.stream() .filter(r -> r.getResourcePlural().equals("meows")) .findFirst() .get(); assertEquals(1, meow.getSubResources().size()); assertEquals("meows", meow.getResourcePlural()); assertEquals("meow", meow.getResourceSingular()); assertEquals(true, meow.getNamespaced()); assertEquals("mouse", meow.getSubResources().get(0)); }
|
public Set<APIResource> groupResourcesByName( String group, List<String> versions, String preferredVersion, V1APIResourceList resourceList) { Set<APIResource> resources = resourceList.getResources().stream() .filter(r -> !getSubResourceNameIfPossible(r.getName()).isPresent()) .map( r -> new APIResource( group, versions, preferredVersion, r.getKind(), r.getNamespaced(), r.getName(), r.getSingularName())) .collect(Collectors.toSet()); Map<String, Set<String>> subResources = manageRelationFromResourceToSubResources(resourceList); resources.stream() .forEach( r -> { if (subResources.containsKey(r.getResourcePlural())) { r.subResources.addAll(subResources.get(r.getResourcePlural())); } }); return resources; }
|
Discovery { public Set<APIResource> groupResourcesByName( String group, List<String> versions, String preferredVersion, V1APIResourceList resourceList) { Set<APIResource> resources = resourceList.getResources().stream() .filter(r -> !getSubResourceNameIfPossible(r.getName()).isPresent()) .map( r -> new APIResource( group, versions, preferredVersion, r.getKind(), r.getNamespaced(), r.getName(), r.getSingularName())) .collect(Collectors.toSet()); Map<String, Set<String>> subResources = manageRelationFromResourceToSubResources(resourceList); resources.stream() .forEach( r -> { if (subResources.containsKey(r.getResourcePlural())) { r.subResources.addAll(subResources.get(r.getResourcePlural())); } }); return resources; } }
|
Discovery { public Set<APIResource> groupResourcesByName( String group, List<String> versions, String preferredVersion, V1APIResourceList resourceList) { Set<APIResource> resources = resourceList.getResources().stream() .filter(r -> !getSubResourceNameIfPossible(r.getName()).isPresent()) .map( r -> new APIResource( group, versions, preferredVersion, r.getKind(), r.getNamespaced(), r.getName(), r.getSingularName())) .collect(Collectors.toSet()); Map<String, Set<String>> subResources = manageRelationFromResourceToSubResources(resourceList); resources.stream() .forEach( r -> { if (subResources.containsKey(r.getResourcePlural())) { r.subResources.addAll(subResources.get(r.getResourcePlural())); } }); return resources; } Discovery(); Discovery(ApiClient apiClient); }
|
Discovery { public Set<APIResource> groupResourcesByName( String group, List<String> versions, String preferredVersion, V1APIResourceList resourceList) { Set<APIResource> resources = resourceList.getResources().stream() .filter(r -> !getSubResourceNameIfPossible(r.getName()).isPresent()) .map( r -> new APIResource( group, versions, preferredVersion, r.getKind(), r.getNamespaced(), r.getName(), r.getSingularName())) .collect(Collectors.toSet()); Map<String, Set<String>> subResources = manageRelationFromResourceToSubResources(resourceList); resources.stream() .forEach( r -> { if (subResources.containsKey(r.getResourcePlural())) { r.subResources.addAll(subResources.get(r.getResourcePlural())); } }); return resources; } Discovery(); Discovery(ApiClient apiClient); Set<APIResource> findAll(); Set<APIResource> findAll(String group, List<String> versions, String preferredVersion); Set<APIResource> findAll(
String group, List<String> versions, String preferredVersion, String path); Set<APIResource> groupResourcesByName(
String group,
List<String> versions,
String preferredVersion,
V1APIResourceList resourceList); V1APIVersions legacyCoreApi(); V1APIGroupList groupDiscovery(String path); V1APIVersions versionDiscovery(String path); V1APIResourceList resourceDiscovery(String path); }
|
Discovery { public Set<APIResource> groupResourcesByName( String group, List<String> versions, String preferredVersion, V1APIResourceList resourceList) { Set<APIResource> resources = resourceList.getResources().stream() .filter(r -> !getSubResourceNameIfPossible(r.getName()).isPresent()) .map( r -> new APIResource( group, versions, preferredVersion, r.getKind(), r.getNamespaced(), r.getName(), r.getSingularName())) .collect(Collectors.toSet()); Map<String, Set<String>> subResources = manageRelationFromResourceToSubResources(resourceList); resources.stream() .forEach( r -> { if (subResources.containsKey(r.getResourcePlural())) { r.subResources.addAll(subResources.get(r.getResourcePlural())); } }); return resources; } Discovery(); Discovery(ApiClient apiClient); Set<APIResource> findAll(); Set<APIResource> findAll(String group, List<String> versions, String preferredVersion); Set<APIResource> findAll(
String group, List<String> versions, String preferredVersion, String path); Set<APIResource> groupResourcesByName(
String group,
List<String> versions,
String preferredVersion,
V1APIResourceList resourceList); V1APIVersions legacyCoreApi(); V1APIGroupList groupDiscovery(String path); V1APIVersions versionDiscovery(String path); V1APIResourceList resourceDiscovery(String path); }
|
@Test public void testReflectorRunOnce() throws InterruptedException, ApiException { String mockResourceVersion = "1000"; when(listerWatcher.list(any())) .thenReturn( new V1PodList().metadata(new V1ListMeta().resourceVersion(mockResourceVersion))); when(listerWatcher.watch(any())) .then( (v) -> { Thread.sleep(999999L); return null; }); ReflectorRunnable<V1Pod, V1PodList> reflectorRunnable = new ReflectorRunnable<V1Pod, V1PodList>(V1Pod.class, listerWatcher, deltaFIFO); try { Thread thread = new Thread(reflectorRunnable::run); thread.setDaemon(true); thread.start(); Thread.sleep(1000); verify(deltaFIFO, times(1)).replace(any(), any()); verify(deltaFIFO, never()).add(any()); verify(listerWatcher, times(1)).list(any()); verify(listerWatcher, times(1)).watch(any()); } finally { reflectorRunnable.stop(); } }
|
public void stop() { isActive.set(false); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); void run(); void stop(); String getLastSyncResourceVersion(); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); void run(); void stop(); String getLastSyncResourceVersion(); }
|
@Test public void testReflectorWatchConnectionCloseOnError() throws InterruptedException { Watchable<V1Pod> watch = new MockWatch<V1Pod>( new Watch.Response<V1Pod>(EventType.ERROR.name(), new V1Status().status("403"))); ReflectorRunnable<V1Pod, V1PodList> reflectorRunnable = new ReflectorRunnable<>( V1Pod.class, new ListerWatcher<V1Pod, V1PodList>() { @Override public V1PodList list(CallGeneratorParams params) throws ApiException { return new V1PodList().metadata(new V1ListMeta()); } @Override public Watchable<V1Pod> watch(CallGeneratorParams params) throws ApiException { return watch; } }, deltaFIFO); try { Thread thread = new Thread(reflectorRunnable::run); thread.setDaemon(true); thread.start(); Thread.sleep(1000); assertTrue(((MockWatch<V1Pod>) watch).isClosed()); } finally { reflectorRunnable.stop(); } }
|
public void stop() { isActive.set(false); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); void run(); void stop(); String getLastSyncResourceVersion(); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); void run(); void stop(); String getLastSyncResourceVersion(); }
|
@Test public void testReflectorRunnableCaptureListException() throws ApiException, InterruptedException { RuntimeException expectedException = new RuntimeException("noxu"); AtomicReference<Throwable> actualException = new AtomicReference<>(); when(listerWatcher.list(any())).thenThrow(expectedException); ReflectorRunnable<V1Pod, V1PodList> reflectorRunnable = new ReflectorRunnable<>( V1Pod.class, listerWatcher, deltaFIFO, (apiType, t) -> { actualException.set(t); }); try { Thread thread = new Thread(reflectorRunnable::run); thread.setDaemon(true); thread.start(); Thread.sleep(1000); } finally { reflectorRunnable.stop(); } assertEquals(expectedException, actualException.get()); }
|
public void stop() { isActive.set(false); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); void run(); void stop(); String getLastSyncResourceVersion(); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); void run(); void stop(); String getLastSyncResourceVersion(); }
|
@Test public void testReflectorRunnableCaptureWatchException() throws ApiException, InterruptedException { RuntimeException expectedException = new RuntimeException("noxu"); AtomicReference<Throwable> actualException = new AtomicReference<>(); when(listerWatcher.list(any())).thenReturn(new V1PodList().metadata(new V1ListMeta())); when(listerWatcher.watch(any())).thenThrow(expectedException); ReflectorRunnable<V1Pod, V1PodList> reflectorRunnable = new ReflectorRunnable<>( V1Pod.class, listerWatcher, deltaFIFO, (apiType, t) -> { actualException.set(t); }); try { Thread thread = new Thread(reflectorRunnable::run); thread.setDaemon(true); thread.start(); Thread.sleep(1000); } finally { reflectorRunnable.stop(); } assertEquals(expectedException, actualException.get()); }
|
public void stop() { isActive.set(false); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); void run(); void stop(); String getLastSyncResourceVersion(); }
|
ReflectorRunnable implements Runnable { public void stop() { isActive.set(false); } ReflectorRunnable(
Class<ApiType> apiTypeClass, ListerWatcher listerWatcher, DeltaFIFO store); ReflectorRunnable(
Class<ApiType> apiTypeClass,
ListerWatcher listerWatcher,
DeltaFIFO store,
BiConsumer<Class<ApiType>, Throwable> exceptionHandler); void run(); void stop(); String getLastSyncResourceVersion(); }
|
@Test public void testControllerProcessDeltas() throws InterruptedException { AtomicInteger receivingDeltasCount = new AtomicInteger(0); V1Pod foo1 = new V1Pod().metadata(new V1ObjectMeta().name("foo1").namespace("default")); V1Pod foo2 = new V1Pod().metadata(new V1ObjectMeta().name("foo2").namespace("default")); V1Pod foo3 = new V1Pod().metadata(new V1ObjectMeta().name("foo3").namespace("default")); V1PodList podList = new V1PodList().metadata(new V1ListMeta()).items(Arrays.asList(foo1, foo2, foo3)); DeltaFIFO deltaFIFO = new DeltaFIFO(Caches::deletionHandlingMetaNamespaceKeyFunc, new Cache()); AtomicBoolean runOnce = new AtomicBoolean(false); ListerWatcher<V1Pod, V1PodList> listerWatcher = new MockRunOnceListerWatcher<V1Pod, V1PodList>( podList, new Watch.Response<V1Pod>(EventType.MODIFIED.name(), foo3)); Controller<V1Pod, V1PodList> controller = new Controller<>( V1Pod.class, deltaFIFO, listerWatcher, (deltas) -> { receivingDeltasCount.incrementAndGet(); }); Thread controllerThread = new Thread(controller::run); controllerThread.setDaemon(true); controllerThread.start(); Thread.sleep(1000); try { assertEquals(4, receivingDeltasCount.get()); } catch (Throwable t) { throw new RuntimeException(t); } finally { controller.stop(); } }
|
public void stop() { synchronized (this) { if (reflectorFuture != null) { reflector.stop(); reflectorFuture.cancel(true); } } reflectExecutor.shutdown(); }
|
Controller { public void stop() { synchronized (this) { if (reflectorFuture != null) { reflector.stop(); reflectorFuture.cancel(true); } } reflectExecutor.shutdown(); } }
|
Controller { public void stop() { synchronized (this) { if (reflectorFuture != null) { reflector.stop(); reflectorFuture.cancel(true); } } reflectExecutor.shutdown(); } Controller(
Class<ApiType> apiTypeClass,
DeltaFIFO queue,
ListerWatcher<ApiType, ApiListType> listerWatcher,
Consumer<Deque<MutablePair<DeltaFIFO.DeltaType, KubernetesObject>>> processFunc,
Supplier<Boolean> resyncFunc,
long fullResyncPeriod); Controller(
Class<ApiType> apiTypeClass,
DeltaFIFO queue,
ListerWatcher<ApiType, ApiListType> listerWatcher,
Consumer<Deque<MutablePair<DeltaFIFO.DeltaType, KubernetesObject>>> popProcessFunc); }
|
Controller { public void stop() { synchronized (this) { if (reflectorFuture != null) { reflector.stop(); reflectorFuture.cancel(true); } } reflectExecutor.shutdown(); } Controller(
Class<ApiType> apiTypeClass,
DeltaFIFO queue,
ListerWatcher<ApiType, ApiListType> listerWatcher,
Consumer<Deque<MutablePair<DeltaFIFO.DeltaType, KubernetesObject>>> processFunc,
Supplier<Boolean> resyncFunc,
long fullResyncPeriod); Controller(
Class<ApiType> apiTypeClass,
DeltaFIFO queue,
ListerWatcher<ApiType, ApiListType> listerWatcher,
Consumer<Deque<MutablePair<DeltaFIFO.DeltaType, KubernetesObject>>> popProcessFunc); void run(); void stop(); boolean hasSynced(); String lastSyncResourceVersion(); }
|
Controller { public void stop() { synchronized (this) { if (reflectorFuture != null) { reflector.stop(); reflectorFuture.cancel(true); } } reflectExecutor.shutdown(); } Controller(
Class<ApiType> apiTypeClass,
DeltaFIFO queue,
ListerWatcher<ApiType, ApiListType> listerWatcher,
Consumer<Deque<MutablePair<DeltaFIFO.DeltaType, KubernetesObject>>> processFunc,
Supplier<Boolean> resyncFunc,
long fullResyncPeriod); Controller(
Class<ApiType> apiTypeClass,
DeltaFIFO queue,
ListerWatcher<ApiType, ApiListType> listerWatcher,
Consumer<Deque<MutablePair<DeltaFIFO.DeltaType, KubernetesObject>>> popProcessFunc); void run(); void stop(); boolean hasSynced(); String lastSyncResourceVersion(); }
|
@Test public void testDefaultNamespaceNameKey() { String testName = "test-name"; String testNamespace = "test-namespace"; V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name(testName).namespace(testNamespace)); assertEquals(testNamespace + "/" + testName, Caches.metaNamespaceKeyFunc(pod)); }
|
public static String metaNamespaceKeyFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (!Strings.isNullOrEmpty(metadata.getNamespace())) { return metadata.getNamespace() + "/" + metadata.getName(); } return metadata.getName(); }
|
Caches { public static String metaNamespaceKeyFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (!Strings.isNullOrEmpty(metadata.getNamespace())) { return metadata.getNamespace() + "/" + metadata.getName(); } return metadata.getName(); } }
|
Caches { public static String metaNamespaceKeyFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (!Strings.isNullOrEmpty(metadata.getNamespace())) { return metadata.getNamespace() + "/" + metadata.getName(); } return metadata.getName(); } }
|
Caches { public static String metaNamespaceKeyFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (!Strings.isNullOrEmpty(metadata.getNamespace())) { return metadata.getNamespace() + "/" + metadata.getName(); } return metadata.getName(); } static String deletionHandlingMetaNamespaceKeyFunc(
ApiType object); static String metaNamespaceKeyFunc(KubernetesObject obj); static List<String> metaNamespaceIndexFunc(KubernetesObject obj); }
|
Caches { public static String metaNamespaceKeyFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (!Strings.isNullOrEmpty(metadata.getNamespace())) { return metadata.getNamespace() + "/" + metadata.getName(); } return metadata.getName(); } static String deletionHandlingMetaNamespaceKeyFunc(
ApiType object); static String metaNamespaceKeyFunc(KubernetesObject obj); static List<String> metaNamespaceIndexFunc(KubernetesObject obj); static final String NAMESPACE_INDEX; }
|
@Test public void testDefaultNamespaceIndex() { String testName = "test-name"; String testNamespace = "test-namespace"; V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name(testName).namespace(testNamespace)); List<String> indices = Caches.metaNamespaceIndexFunc(pod); assertEquals(pod.getMetadata().getNamespace(), indices.get(0)); }
|
public static List<String> metaNamespaceIndexFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (metadata == null) { return Collections.emptyList(); } return Collections.singletonList(metadata.getNamespace()); }
|
Caches { public static List<String> metaNamespaceIndexFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (metadata == null) { return Collections.emptyList(); } return Collections.singletonList(metadata.getNamespace()); } }
|
Caches { public static List<String> metaNamespaceIndexFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (metadata == null) { return Collections.emptyList(); } return Collections.singletonList(metadata.getNamespace()); } }
|
Caches { public static List<String> metaNamespaceIndexFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (metadata == null) { return Collections.emptyList(); } return Collections.singletonList(metadata.getNamespace()); } static String deletionHandlingMetaNamespaceKeyFunc(
ApiType object); static String metaNamespaceKeyFunc(KubernetesObject obj); static List<String> metaNamespaceIndexFunc(KubernetesObject obj); }
|
Caches { public static List<String> metaNamespaceIndexFunc(KubernetesObject obj) { V1ObjectMeta metadata = obj.getMetadata(); if (metadata == null) { return Collections.emptyList(); } return Collections.singletonList(metadata.getNamespace()); } static String deletionHandlingMetaNamespaceKeyFunc(
ApiType object); static String metaNamespaceKeyFunc(KubernetesObject obj); static List<String> metaNamespaceIndexFunc(KubernetesObject obj); static final String NAMESPACE_INDEX; }
|
@Test public void testAddIndexers() { Cache<V1Pod> podCache = new Cache<>(); String nodeIndex = "node-index"; String clusterIndex = "cluster-index"; Map<String, Function<V1Pod, List<String>>> indexers = new HashMap<>(); indexers.put( nodeIndex, (V1Pod pod) -> { return Arrays.asList(pod.getSpec().getNodeName()); }); indexers.put( clusterIndex, (V1Pod pod) -> { return Arrays.asList(pod.getMetadata().getClusterName()); }); podCache.addIndexers(indexers); V1Pod testPod = new V1Pod() .metadata(new V1ObjectMeta().namespace("ns").name("n").clusterName("cluster1")) .spec(new V1PodSpec().nodeName("node1")); podCache.add(testPod); List<V1Pod> namespaceIndexedPods = podCache.byIndex(Caches.NAMESPACE_INDEX, "ns"); assertEquals(1, namespaceIndexedPods.size()); List<V1Pod> nodeNameIndexedPods = podCache.byIndex(nodeIndex, "node1"); assertEquals(1, nodeNameIndexedPods.size()); List<V1Pod> clusterNameIndexedPods = podCache.byIndex(clusterIndex, "cluster1"); assertEquals(1, clusterNameIndexedPods.size()); }
|
@Override public void addIndexers(Map<String, Function<ApiType, List<String>>> newIndexers) { if (!items.isEmpty()) { throw new IllegalStateException("cannot add indexers to a non-empty cache"); } Set<String> oldKeys = indexers.keySet(); Set<String> newKeys = newIndexers.keySet(); Set<String> intersection = new HashSet<>(oldKeys); intersection.retainAll(newKeys); if (!intersection.isEmpty()) { throw new IllegalArgumentException("indexer conflict: " + intersection); } for (Map.Entry<String, Function<ApiType, List<String>>> indexEntry : newIndexers.entrySet()) { addIndexFunc(indexEntry.getKey(), indexEntry.getValue()); } }
|
Cache implements Indexer<ApiType> { @Override public void addIndexers(Map<String, Function<ApiType, List<String>>> newIndexers) { if (!items.isEmpty()) { throw new IllegalStateException("cannot add indexers to a non-empty cache"); } Set<String> oldKeys = indexers.keySet(); Set<String> newKeys = newIndexers.keySet(); Set<String> intersection = new HashSet<>(oldKeys); intersection.retainAll(newKeys); if (!intersection.isEmpty()) { throw new IllegalArgumentException("indexer conflict: " + intersection); } for (Map.Entry<String, Function<ApiType, List<String>>> indexEntry : newIndexers.entrySet()) { addIndexFunc(indexEntry.getKey(), indexEntry.getValue()); } } }
|
Cache implements Indexer<ApiType> { @Override public void addIndexers(Map<String, Function<ApiType, List<String>>> newIndexers) { if (!items.isEmpty()) { throw new IllegalStateException("cannot add indexers to a non-empty cache"); } Set<String> oldKeys = indexers.keySet(); Set<String> newKeys = newIndexers.keySet(); Set<String> intersection = new HashSet<>(oldKeys); intersection.retainAll(newKeys); if (!intersection.isEmpty()) { throw new IllegalArgumentException("indexer conflict: " + intersection); } for (Map.Entry<String, Function<ApiType, List<String>>> indexEntry : newIndexers.entrySet()) { addIndexFunc(indexEntry.getKey(), indexEntry.getValue()); } } Cache(); Cache(
String indexName,
Function<ApiType, List<String>> indexFunc,
Function<ApiType, String> keyFunc); }
|
Cache implements Indexer<ApiType> { @Override public void addIndexers(Map<String, Function<ApiType, List<String>>> newIndexers) { if (!items.isEmpty()) { throw new IllegalStateException("cannot add indexers to a non-empty cache"); } Set<String> oldKeys = indexers.keySet(); Set<String> newKeys = newIndexers.keySet(); Set<String> intersection = new HashSet<>(oldKeys); intersection.retainAll(newKeys); if (!intersection.isEmpty()) { throw new IllegalArgumentException("indexer conflict: " + intersection); } for (Map.Entry<String, Function<ApiType, List<String>>> indexEntry : newIndexers.entrySet()) { addIndexFunc(indexEntry.getKey(), indexEntry.getValue()); } } Cache(); Cache(
String indexName,
Function<ApiType, List<String>> indexFunc,
Function<ApiType, String> keyFunc); @Override void add(ApiType obj); @Override void update(ApiType obj); @Override void delete(ApiType obj); @Override synchronized void replace(List<ApiType> list, String resourceVersion); @Override void resync(); @Override synchronized List<String> listKeys(); @Override ApiType get(ApiType obj); @Override synchronized List<ApiType> list(); @Override synchronized ApiType getByKey(String key); @Override synchronized List<ApiType> index(String indexName, ApiType obj); @Override synchronized List<String> indexKeys(String indexName, String indexKey); @Override synchronized List<ApiType> byIndex(String indexName, String indexKey); @Override Map<String, Function<ApiType, List<String>>> getIndexers(); @Override void addIndexers(Map<String, Function<ApiType, List<String>>> newIndexers); void updateIndices(ApiType oldObj, ApiType newObj, String key); void addIndexFunc(String indexName, Function<ApiType, List<String>> indexFunc); Function<ApiType, String> getKeyFunc(); void setKeyFunc(Function<ApiType, String> keyFunc); }
|
Cache implements Indexer<ApiType> { @Override public void addIndexers(Map<String, Function<ApiType, List<String>>> newIndexers) { if (!items.isEmpty()) { throw new IllegalStateException("cannot add indexers to a non-empty cache"); } Set<String> oldKeys = indexers.keySet(); Set<String> newKeys = newIndexers.keySet(); Set<String> intersection = new HashSet<>(oldKeys); intersection.retainAll(newKeys); if (!intersection.isEmpty()) { throw new IllegalArgumentException("indexer conflict: " + intersection); } for (Map.Entry<String, Function<ApiType, List<String>>> indexEntry : newIndexers.entrySet()) { addIndexFunc(indexEntry.getKey(), indexEntry.getValue()); } } Cache(); Cache(
String indexName,
Function<ApiType, List<String>> indexFunc,
Function<ApiType, String> keyFunc); @Override void add(ApiType obj); @Override void update(ApiType obj); @Override void delete(ApiType obj); @Override synchronized void replace(List<ApiType> list, String resourceVersion); @Override void resync(); @Override synchronized List<String> listKeys(); @Override ApiType get(ApiType obj); @Override synchronized List<ApiType> list(); @Override synchronized ApiType getByKey(String key); @Override synchronized List<ApiType> index(String indexName, ApiType obj); @Override synchronized List<String> indexKeys(String indexName, String indexKey); @Override synchronized List<ApiType> byIndex(String indexName, String indexKey); @Override Map<String, Function<ApiType, List<String>>> getIndexers(); @Override void addIndexers(Map<String, Function<ApiType, List<String>>> newIndexers); void updateIndices(ApiType oldObj, ApiType newObj, String key); void addIndexFunc(String indexName, Function<ApiType, List<String>> indexFunc); Function<ApiType, String> getKeyFunc(); void setKeyFunc(Function<ApiType, String> keyFunc); }
|
@Test public void testNotificationHandling() throws InterruptedException { V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name("foo").namespace("default")); ProcessorListener<V1Pod> listener = new ProcessorListener<>( new ResourceEventHandler<V1Pod>() { @Override public void onAdd(V1Pod obj) { assertEquals(pod, obj); addNotificationReceived = true; } @Override public void onUpdate(V1Pod oldObj, V1Pod newObj) { assertEquals(pod, newObj); updateNotificationReceived = true; } @Override public void onDelete(V1Pod obj, boolean deletedFinalStateUnknown) { assertEquals(pod, obj); deleteNotificationReceived = true; } }, 0); listener.add(new ProcessorListener.AddNotification<>(pod)); listener.add(new ProcessorListener.UpdateNotification<>(null, pod)); listener.add(new ProcessorListener.DeleteNotification<>(pod)); Thread listenerThread = new Thread(listener::run); listenerThread.setDaemon(true); listenerThread.start(); Thread.sleep(1000); assertTrue(addNotificationReceived); assertTrue(updateNotificationReceived); assertTrue(deleteNotificationReceived); }
|
public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); }
|
ProcessorListener implements Runnable { public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); } }
|
ProcessorListener implements Runnable { public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); } ProcessorListener(ResourceEventHandler<ApiType> handler, long resyncPeriod); }
|
ProcessorListener implements Runnable { public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); } ProcessorListener(ResourceEventHandler<ApiType> handler, long resyncPeriod); @Override void run(); void add(Notification<ApiType> obj); void determineNextResync(DateTime now); boolean shouldResync(DateTime now); }
|
ProcessorListener implements Runnable { public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); } ProcessorListener(ResourceEventHandler<ApiType> handler, long resyncPeriod); @Override void run(); void add(Notification<ApiType> obj); void determineNextResync(DateTime now); boolean shouldResync(DateTime now); }
|
@Test public void testNonZeroBadIntExit() { InputStream inputStream = new ByteArrayInputStream(OUTPUT_EXIT_BAD_INT.getBytes(StandardCharsets.UTF_8)); int exitCode = Exec.parseExitCode(client, inputStream); assertEquals(-1, exitCode); }
|
static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; }
|
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; } }
|
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; } Exec(); Exec(ApiClient apiClient); }
|
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; } Exec(); Exec(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); ExecutionBuilder newExecutionBuilder(String namespace, String name, String[] command); Process exec(String namespace, String name, String[] command, boolean stdin); Process exec(V1Pod pod, String[] command, boolean stdin); Process exec(String namespace, String name, String[] command, boolean stdin, boolean tty); Process exec(V1Pod pod, String[] command, boolean stdin, boolean tty); Process exec(V1Pod pod, String[] command, String container, boolean stdin, boolean tty); Process exec(
String namespace, String name, String[] command, String container, boolean stdin, boolean tty); }
|
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if (status == null) { return -1; } if (V1STATUS_SUCCESS.equals(status.getStatus())) return 0; if (V1STATUS_REASON_NONZEROEXITCODE.equals(status.getReason())) { V1StatusDetails details = status.getDetails(); if (details != null) { List<V1StatusCause> causes = details.getCauses(); if (causes != null) { for (V1StatusCause cause : causes) { if (V1STATUS_CAUSE_REASON_EXITCODE.equals(cause.getReason())) { try { return Integer.parseInt(cause.getMessage()); } catch (NumberFormatException nfe) { log.error("Error parsing exit code from status channel response", nfe); } } } } } } } catch (Throwable t) { log.error("Error parsing exit code from status channel response", t); } return -1; } Exec(); Exec(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); ExecutionBuilder newExecutionBuilder(String namespace, String name, String[] command); Process exec(String namespace, String name, String[] command, boolean stdin); Process exec(V1Pod pod, String[] command, boolean stdin); Process exec(String namespace, String name, String[] command, boolean stdin, boolean tty); Process exec(V1Pod pod, String[] command, boolean stdin, boolean tty); Process exec(V1Pod pod, String[] command, String container, boolean stdin, boolean tty); Process exec(
String namespace, String name, String[] command, String container, boolean stdin, boolean tty); }
|
@Test public void testMultipleNotificationsHandling() throws InterruptedException { V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name("foo").namespace("default")); final int[] count = {0}; ProcessorListener<V1Pod> listener = new ProcessorListener<>( new ResourceEventHandler<V1Pod>() { @Override public void onAdd(V1Pod obj) { assertEquals(pod, obj); count[0]++; } @Override public void onUpdate(V1Pod oldObj, V1Pod newObj) {} @Override public void onDelete(V1Pod obj, boolean deletedFinalStateUnknown) {} }, 0); for (int i = 0; i < 2000; i++) { listener.add(new ProcessorListener.AddNotification<>(pod)); } Thread listenerThread = new Thread(listener); listenerThread.setDaemon(true); listenerThread.start(); Thread.sleep(2000); assertEquals(count[0], 2000); }
|
public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); }
|
ProcessorListener implements Runnable { public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); } }
|
ProcessorListener implements Runnable { public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); } ProcessorListener(ResourceEventHandler<ApiType> handler, long resyncPeriod); }
|
ProcessorListener implements Runnable { public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); } ProcessorListener(ResourceEventHandler<ApiType> handler, long resyncPeriod); @Override void run(); void add(Notification<ApiType> obj); void determineNextResync(DateTime now); boolean shouldResync(DateTime now); }
|
ProcessorListener implements Runnable { public void add(Notification<ApiType> obj) { if (obj == null) { return; } this.queue.add(obj); } ProcessorListener(ResourceEventHandler<ApiType> handler, long resyncPeriod); @Override void run(); void add(Notification<ApiType> obj); void determineNextResync(DateTime now); boolean shouldResync(DateTime now); }
|
@Test public void testUrl() throws IOException, ApiException, InterruptedException { Copy copy = new Copy(client); V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name(podName).namespace(namespace)); wireMockRule.stubFor( get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec")) .willReturn( aResponse() .withStatus(404) .withHeader("Content-Type", "application/json") .withBody("{}"))); try { copy.copyFileFromPod(pod, "container", "/some/path/to/file"); } catch (IOException | ApiException e) { e.printStackTrace(); } Thread.sleep(2000); wireMockRule.verify( getRequestedFor( urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec")) .withQueryParam("stdin", equalTo("false")) .withQueryParam("stdout", equalTo("true")) .withQueryParam("stderr", equalTo("true")) .withQueryParam("tty", equalTo("false")) .withQueryParam("command", new AnythingPattern())); }
|
public InputStream copyFileFromPod(String namespace, String pod, String srcPath) throws ApiException, IOException { return copyFileFromPod(namespace, pod, null, srcPath); }
|
Copy extends Exec { public InputStream copyFileFromPod(String namespace, String pod, String srcPath) throws ApiException, IOException { return copyFileFromPod(namespace, pod, null, srcPath); } }
|
Copy extends Exec { public InputStream copyFileFromPod(String namespace, String pod, String srcPath) throws ApiException, IOException { return copyFileFromPod(namespace, pod, null, srcPath); } Copy(); Copy(ApiClient apiClient); }
|
Copy extends Exec { public InputStream copyFileFromPod(String namespace, String pod, String srcPath) throws ApiException, IOException { return copyFileFromPod(namespace, pod, null, srcPath); } Copy(); Copy(ApiClient apiClient); InputStream copyFileFromPod(String namespace, String pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String container, String srcPath); InputStream copyFileFromPod(String namespace, String pod, String container, String srcPath); void copyFileFromPod(
String namespace, String name, String container, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(String namespace, String pod, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace, String pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace,
String pod,
String container,
String srcPath,
Path destination,
boolean enableTarCompressing); static void copyFileFromPod(String namespace, String pod, String srcPath, Path dest); void copyFileToPod(
String namespace, String pod, String container, Path srcPath, Path destPath); void copyFileToPod(
String namespace, String pod, String container, byte[] src, Path destPath); }
|
Copy extends Exec { public InputStream copyFileFromPod(String namespace, String pod, String srcPath) throws ApiException, IOException { return copyFileFromPod(namespace, pod, null, srcPath); } Copy(); Copy(ApiClient apiClient); InputStream copyFileFromPod(String namespace, String pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String container, String srcPath); InputStream copyFileFromPod(String namespace, String pod, String container, String srcPath); void copyFileFromPod(
String namespace, String name, String container, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(String namespace, String pod, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace, String pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace,
String pod,
String container,
String srcPath,
Path destination,
boolean enableTarCompressing); static void copyFileFromPod(String namespace, String pod, String srcPath, Path dest); void copyFileToPod(
String namespace, String pod, String container, Path srcPath, Path destPath); void copyFileToPod(
String namespace, String pod, String container, byte[] src, Path destPath); }
|
@Test public void testCopyFileToPod() throws IOException, InterruptedException { File testFile = File.createTempFile("testfile", null); testFile.deleteOnExit(); Copy copy = new Copy(client); wireMockRule.stubFor( get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec")) .willReturn( aResponse() .withStatus(404) .withHeader("Content-Type", "application/json") .withBody("{}"))); Thread t = new Thread( new Runnable() { public void run() { try { copy.copyFileToPod( namespace, podName, "", testFile.toPath(), Paths.get("/copied-testfile")); } catch (IOException | ApiException ex) { ex.printStackTrace(); } } }); t.start(); Thread.sleep(2000); t.interrupt(); wireMockRule.verify( getRequestedFor( urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec")) .withQueryParam("stdin", equalTo("true")) .withQueryParam("stdout", equalTo("true")) .withQueryParam("stderr", equalTo("true")) .withQueryParam("tty", equalTo("false")) .withQueryParam("command", equalTo("sh")) .withQueryParam("command", equalTo("-c")) .withQueryParam("command", equalTo("base64 -d | tar -xmf - -C /"))); }
|
public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } }
|
Copy extends Exec { public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } } }
|
Copy extends Exec { public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } } Copy(); Copy(ApiClient apiClient); }
|
Copy extends Exec { public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } } Copy(); Copy(ApiClient apiClient); InputStream copyFileFromPod(String namespace, String pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String container, String srcPath); InputStream copyFileFromPod(String namespace, String pod, String container, String srcPath); void copyFileFromPod(
String namespace, String name, String container, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(String namespace, String pod, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace, String pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace,
String pod,
String container,
String srcPath,
Path destination,
boolean enableTarCompressing); static void copyFileFromPod(String namespace, String pod, String srcPath, Path dest); void copyFileToPod(
String namespace, String pod, String container, Path srcPath, Path destPath); void copyFileToPod(
String namespace, String pod, String container, byte[] src, Path destPath); }
|
Copy extends Exec { public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } } Copy(); Copy(ApiClient apiClient); InputStream copyFileFromPod(String namespace, String pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String container, String srcPath); InputStream copyFileFromPod(String namespace, String pod, String container, String srcPath); void copyFileFromPod(
String namespace, String name, String container, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(String namespace, String pod, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace, String pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace,
String pod,
String container,
String srcPath,
Path destination,
boolean enableTarCompressing); static void copyFileFromPod(String namespace, String pod, String srcPath, Path dest); void copyFileToPod(
String namespace, String pod, String container, Path srcPath, Path destPath); void copyFileToPod(
String namespace, String pod, String container, byte[] src, Path destPath); }
|
@Test public void testCopyBinaryDataToPod() throws InterruptedException { byte[] testSrc = new byte[0]; Copy copy = new Copy(client); wireMockRule.stubFor( get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec")) .willReturn( aResponse() .withStatus(404) .withHeader("Content-Type", "application/json") .withBody("{}"))); Thread t = new Thread( new Runnable() { public void run() { try { copy.copyFileToPod( namespace, podName, "", testSrc, Paths.get("/copied-binarydata")); } catch (IOException | ApiException ex) { ex.printStackTrace(); } } }); t.start(); Thread.sleep(2000); t.interrupt(); wireMockRule.verify( getRequestedFor( urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec")) .withQueryParam("stdin", equalTo("true")) .withQueryParam("stdout", equalTo("true")) .withQueryParam("stderr", equalTo("true")) .withQueryParam("tty", equalTo("false")) .withQueryParam("command", equalTo("sh")) .withQueryParam("command", equalTo("-c")) .withQueryParam("command", equalTo("base64 -d | tar -xmf - -C /"))); }
|
public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } }
|
Copy extends Exec { public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } } }
|
Copy extends Exec { public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } } Copy(); Copy(ApiClient apiClient); }
|
Copy extends Exec { public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } } Copy(); Copy(ApiClient apiClient); InputStream copyFileFromPod(String namespace, String pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String container, String srcPath); InputStream copyFileFromPod(String namespace, String pod, String container, String srcPath); void copyFileFromPod(
String namespace, String name, String container, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(String namespace, String pod, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace, String pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace,
String pod,
String container,
String srcPath,
Path destination,
boolean enableTarCompressing); static void copyFileFromPod(String namespace, String pod, String srcPath, Path dest); void copyFileToPod(
String namespace, String pod, String container, Path srcPath, Path destPath); void copyFileToPod(
String namespace, String pod, String container, byte[] src, Path destPath); }
|
Copy extends Exec { public void copyFileToPod( String namespace, String pod, String container, Path srcPath, Path destPath) throws ApiException, IOException { final Process proc = execCopyToPod(namespace, pod, container, destPath); File srcFile = new File(srcPath.toUri()); try (ArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream( new Base64OutputStream(proc.getOutputStream(), true, 0, null)); FileInputStream input = new FileInputStream(srcFile)) { ArchiveEntry tarEntry = new TarArchiveEntry(srcFile, destPath.getFileName().toString()); archiveOutputStream.putArchiveEntry(tarEntry); ByteStreams.copy(input, archiveOutputStream); archiveOutputStream.closeArchiveEntry(); } finally { proc.destroy(); } } Copy(); Copy(ApiClient apiClient); InputStream copyFileFromPod(String namespace, String pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String srcPath); InputStream copyFileFromPod(V1Pod pod, String container, String srcPath); InputStream copyFileFromPod(String namespace, String pod, String container, String srcPath); void copyFileFromPod(
String namespace, String name, String container, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String srcPath, Path destination); void copyDirectoryFromPod(V1Pod pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(String namespace, String pod, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace, String pod, String container, String srcPath, Path destination); void copyDirectoryFromPod(
String namespace,
String pod,
String container,
String srcPath,
Path destination,
boolean enableTarCompressing); static void copyFileFromPod(String namespace, String pod, String srcPath, Path dest); void copyFileToPod(
String namespace, String pod, String container, Path srcPath, Path destPath); void copyFileToPod(
String namespace, String pod, String container, byte[] src, Path destPath); }
|
@Test public void parse() { assertEquals(new GroupVersion("", "v1"), GroupVersion.parse(new V1Pod().apiVersion("v1"))); assertEquals( new GroupVersion("apps", "v1"), GroupVersion.parse(new V1Deployment().apiVersion("apps/v1"))); assertThrows( IllegalArgumentException.class, () -> { GroupVersion.parse(new V1Pod()); GroupVersion.parse(new V1Pod().apiVersion(null)); GroupVersion.parse(new V1Pod().apiVersion("foo/bar/f")); }); }
|
public static GroupVersion parse(String apiVersion) { if (Strings.isNullOrEmpty(apiVersion)) { throw new IllegalArgumentException("No apiVersion found on object"); } if ("v1".equals(apiVersion)) { return new GroupVersion("", "v1"); } String[] parts = apiVersion.split("/"); if (parts.length != 2) { throw new IllegalArgumentException("Invalid apiVersion found on object: " + apiVersion); } return new GroupVersion(parts[0], parts[1]); }
|
GroupVersion { public static GroupVersion parse(String apiVersion) { if (Strings.isNullOrEmpty(apiVersion)) { throw new IllegalArgumentException("No apiVersion found on object"); } if ("v1".equals(apiVersion)) { return new GroupVersion("", "v1"); } String[] parts = apiVersion.split("/"); if (parts.length != 2) { throw new IllegalArgumentException("Invalid apiVersion found on object: " + apiVersion); } return new GroupVersion(parts[0], parts[1]); } }
|
GroupVersion { public static GroupVersion parse(String apiVersion) { if (Strings.isNullOrEmpty(apiVersion)) { throw new IllegalArgumentException("No apiVersion found on object"); } if ("v1".equals(apiVersion)) { return new GroupVersion("", "v1"); } String[] parts = apiVersion.split("/"); if (parts.length != 2) { throw new IllegalArgumentException("Invalid apiVersion found on object: " + apiVersion); } return new GroupVersion(parts[0], parts[1]); } GroupVersion(String group, String version); }
|
GroupVersion { public static GroupVersion parse(String apiVersion) { if (Strings.isNullOrEmpty(apiVersion)) { throw new IllegalArgumentException("No apiVersion found on object"); } if ("v1".equals(apiVersion)) { return new GroupVersion("", "v1"); } String[] parts = apiVersion.split("/"); if (parts.length != 2) { throw new IllegalArgumentException("Invalid apiVersion found on object: " + apiVersion); } return new GroupVersion(parts[0], parts[1]); } GroupVersion(String group, String version); static GroupVersion parse(String apiVersion); static GroupVersion parse(KubernetesObject obj); String getGroup(); String getVersion(); @Override boolean equals(Object o); @Override int hashCode(); }
|
GroupVersion { public static GroupVersion parse(String apiVersion) { if (Strings.isNullOrEmpty(apiVersion)) { throw new IllegalArgumentException("No apiVersion found on object"); } if ("v1".equals(apiVersion)) { return new GroupVersion("", "v1"); } String[] parts = apiVersion.split("/"); if (parts.length != 2) { throw new IllegalArgumentException("Invalid apiVersion found on object: " + apiVersion); } return new GroupVersion(parts[0], parts[1]); } GroupVersion(String group, String version); static GroupVersion parse(String apiVersion); static GroupVersion parse(KubernetesObject obj); String getGroup(); String getVersion(); @Override boolean equals(Object o); @Override int hashCode(); }
|
@Test public void testNotFound() throws ApiException, IOException { V1Pod pod = new V1Pod() .metadata(new V1ObjectMeta().name(podName).namespace(namespace)) .spec( new V1PodSpec() .containers(Arrays.asList(new V1Container().name(container).image("nginx")))); wireMockRule.stubFor( get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/log")) .willReturn( aResponse() .withStatus(404) .withHeader("Content-Type", "text/plain") .withBody("Not Found"))); PodLogs logs = new PodLogs(client); boolean thrown = false; try { logs.streamNamespacedPodLog(pod); } catch (ApiException ex) { assertEquals(404, ex.getCode()); thrown = true; } assertEquals(thrown, true); wireMockRule.verify( getRequestedFor( urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/log")) .withQueryParam("container", equalTo(container)) .withQueryParam("follow", equalTo("true")) .withQueryParam("pretty", equalTo("false")) .withQueryParam("previous", equalTo("false")) .withQueryParam("timestamps", equalTo("false"))); }
|
public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); }
|
PodLogs { public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); } }
|
PodLogs { public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); } PodLogs(); PodLogs(ApiClient apiClient); }
|
PodLogs { public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); } PodLogs(); PodLogs(ApiClient apiClient); ApiClient getApiClient(); InputStream streamNamespacedPodLog(V1Pod pod); InputStream streamNamespacedPodLog(String namespace, String name, String container); InputStream streamNamespacedPodLog(
String namespace,
String name,
String container,
Integer sinceSeconds,
Integer tailLines,
boolean timestamps); }
|
PodLogs { public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); } PodLogs(); PodLogs(ApiClient apiClient); ApiClient getApiClient(); InputStream streamNamespacedPodLog(V1Pod pod); InputStream streamNamespacedPodLog(String namespace, String name, String container); InputStream streamNamespacedPodLog(
String namespace,
String name,
String container,
Integer sinceSeconds,
Integer tailLines,
boolean timestamps); }
|
@Test public void testStream() throws ApiException, IOException { V1Pod pod = new V1Pod() .metadata(new V1ObjectMeta().name(podName).namespace(namespace)) .spec( new V1PodSpec() .containers(Arrays.asList(new V1Container().name(container).image("nginx")))); String content = "this is some\n content for \n various logs \n done"; wireMockRule.stubFor( get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/log")) .willReturn( aResponse() .withStatus(200) .withHeader("Content-Type", "text/plain") .withBody(content))); PodLogs logs = new PodLogs(client); InputStream is = logs.streamNamespacedPodLog(pod); wireMockRule.verify( getRequestedFor( urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/log")) .withQueryParam("container", equalTo(container)) .withQueryParam("follow", equalTo("true")) .withQueryParam("pretty", equalTo("false")) .withQueryParam("previous", equalTo("false")) .withQueryParam("timestamps", equalTo("false"))); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteStreams.copy(is, bos); assertEquals(content, bos.toString()); }
|
public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); }
|
PodLogs { public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); } }
|
PodLogs { public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); } PodLogs(); PodLogs(ApiClient apiClient); }
|
PodLogs { public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); } PodLogs(); PodLogs(ApiClient apiClient); ApiClient getApiClient(); InputStream streamNamespacedPodLog(V1Pod pod); InputStream streamNamespacedPodLog(String namespace, String name, String container); InputStream streamNamespacedPodLog(
String namespace,
String name,
String container,
Integer sinceSeconds,
Integer tailLines,
boolean timestamps); }
|
PodLogs { public InputStream streamNamespacedPodLog(V1Pod pod) throws ApiException, IOException { if (pod.getSpec() == null) { throw new ApiException("pod.spec is null and container isn't specified."); } if (pod.getSpec().getContainers() == null || pod.getSpec().getContainers().size() < 1) { throw new ApiException("pod.spec.containers has no containers"); } return streamNamespacedPodLog( pod.getMetadata().getNamespace(), pod.getMetadata().getName(), pod.getSpec().getContainers().get(0).getName()); } PodLogs(); PodLogs(ApiClient apiClient); ApiClient getApiClient(); InputStream streamNamespacedPodLog(V1Pod pod); InputStream streamNamespacedPodLog(String namespace, String name, String container); InputStream streamNamespacedPodLog(
String namespace,
String name,
String container,
Integer sinceSeconds,
Integer tailLines,
boolean timestamps); }
|
@Test public void testSerializeByteArray() { final JSON json = new JSON(); final String plainText = "string that contains '=' when encoded"; final String base64String = json.serialize(plainText.getBytes()); final String pureString = base64String.replaceAll("^\"|\"$", ""); final ByteString byteStr = ByteString.decodeBase64(pureString); assertNotNull(byteStr); final String decodedText = new String(byteStr.toByteArray()); assertThat(decodedText, is(plainText)); }
|
public String serialize(Object obj) { return gson.toJson(obj); }
|
JSON { public String serialize(Object obj) { return gson.toJson(obj); } }
|
JSON { public String serialize(Object obj) { return gson.toJson(obj); } JSON(); }
|
JSON { public String serialize(Object obj) { return gson.toJson(obj); } JSON(); static GsonBuilder createGson(); Gson getGson(); JSON setGson(Gson gson); JSON setLenientOnJson(boolean lenientOnJson); String serialize(Object obj); @SuppressWarnings("unchecked") T deserialize(String body, Type returnType); JSON setDateTimeFormat(DateTimeFormatter dateFormat); JSON setLocalDateFormat(DateTimeFormatter dateFormat); JSON setDateFormat(DateFormat dateFormat); JSON setSqlDateFormat(DateFormat dateFormat); }
|
JSON { public String serialize(Object obj) { return gson.toJson(obj); } JSON(); static GsonBuilder createGson(); Gson getGson(); JSON setGson(Gson gson); JSON setLenientOnJson(boolean lenientOnJson); String serialize(Object obj); @SuppressWarnings("unchecked") T deserialize(String body, Type returnType); JSON setDateTimeFormat(DateTimeFormatter dateFormat); JSON setLocalDateFormat(DateTimeFormatter dateFormat); JSON setDateFormat(DateFormat dateFormat); JSON setSqlDateFormat(DateFormat dateFormat); }
|
@Test public void whenCreatedWithInt_isInteger() { IntOrString intOrString = new IntOrString(17); assertThat(intOrString.isInteger(), is(true)); }
|
public boolean isInteger() { return isInt; }
|
IntOrString { public boolean isInteger() { return isInt; } }
|
IntOrString { public boolean isInteger() { return isInt; } IntOrString(final String value); IntOrString(final int value); }
|
IntOrString { public boolean isInteger() { return isInt; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
IntOrString { public boolean isInteger() { return isInt; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
@Test public void whenCreatedWithInt_canRetrieveIntValue() { IntOrString intOrString = new IntOrString(17); assertThat(intOrString.getIntValue(), equalTo(17)); }
|
public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; }
|
IntOrString { public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; } }
|
IntOrString { public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; } IntOrString(final String value); IntOrString(final int value); }
|
IntOrString { public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
IntOrString { public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
@Test public void testJsonPatchPod() throws ApiException { CoreV1Api coreV1Api = new CoreV1Api(client); stubFor( patch(urlPathEqualTo("/api/v1/namespaces/default/pods/foo")) .withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_JSON_PATCH)) .willReturn( aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBody("{}"))); PatchUtils.patch( V1Pod.class, () -> coreV1Api.patchNamespacedPodCall( "foo", "default", new V1Patch("[]"), null, null, null, null, null), V1Patch.PATCH_FORMAT_JSON_PATCH, client); verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo"))); }
|
public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat); static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat, ApiClient apiClient); }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat); static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat, ApiClient apiClient); }
|
@Test(expected = IllegalStateException.class) public void whenCreatedWithInt_cannotRetrieveStringValue() { IntOrString intOrString = new IntOrString(17); intOrString.getStrValue(); }
|
public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; }
|
IntOrString { public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; } }
|
IntOrString { public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; } IntOrString(final String value); IntOrString(final int value); }
|
IntOrString { public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
IntOrString { public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
@Test public void whenCreatedWithString_isNotInteger() { IntOrString intOrString = new IntOrString("17"); assertThat(intOrString.isInteger(), is(false)); }
|
public boolean isInteger() { return isInt; }
|
IntOrString { public boolean isInteger() { return isInt; } }
|
IntOrString { public boolean isInteger() { return isInt; } IntOrString(final String value); IntOrString(final int value); }
|
IntOrString { public boolean isInteger() { return isInt; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
IntOrString { public boolean isInteger() { return isInt; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
@Test(expected = IllegalStateException.class) public void whenCreatedWithInt_cannotRetrieveIntValue() { IntOrString intOrString = new IntOrString("17"); intOrString.getIntValue(); }
|
public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; }
|
IntOrString { public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; } }
|
IntOrString { public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; } IntOrString(final String value); IntOrString(final int value); }
|
IntOrString { public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
IntOrString { public Integer getIntValue() { if (!isInt) { throw new IllegalStateException("Not an integer"); } return intValue; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
@Test public void whenCreatedWithString_canRetrieveStringValue() { IntOrString intOrString = new IntOrString("17"); assertThat(intOrString.getStrValue(), equalTo("17")); }
|
public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; }
|
IntOrString { public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; } }
|
IntOrString { public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; } IntOrString(final String value); IntOrString(final int value); }
|
IntOrString { public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
IntOrString { public String getStrValue() { if (isInt) { throw new IllegalStateException("Not a string"); } return strValue; } IntOrString(final String value); IntOrString(final int value); boolean isInteger(); String getStrValue(); Integer getIntValue(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
|
@Test public void testParsePlain() { final Quantity quantity = new QuantityFormatter().parse("1"); assertThat(quantity.getFormat(), is(Quantity.Format.DECIMAL_SI)); assertThat(quantity.getNumber(), is(BigDecimal.valueOf(1))); }
|
public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testParseFractional() { final Quantity quantity = new QuantityFormatter().parse("0.001"); assertThat(quantity.getFormat(), is(Quantity.Format.DECIMAL_SI)); assertThat(quantity.getNumber(), is(BigDecimal.valueOf(0.001))); }
|
public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testParseFractionalUnit() { final Quantity quantity = new QuantityFormatter().parse("0.001m"); assertThat(quantity.getFormat(), is(Quantity.Format.DECIMAL_SI)); assertThat(quantity.getNumber(), is(new BigDecimal("0.000001"))); }
|
public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testParseBinarySi() { final Quantity quantity = new QuantityFormatter().parse("1Ki"); assertThat(quantity.getFormat(), is(Quantity.Format.BINARY_SI)); assertThat(quantity.getNumber(), is(BigDecimal.valueOf(1024))); }
|
public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testParseLargeNumeratorBinarySi() { final Quantity quantity = new QuantityFormatter().parse("32Mi"); assertThat(quantity.getFormat(), is(Quantity.Format.BINARY_SI)); assertThat( quantity.getNumber(), is(BigDecimal.valueOf(2).pow(20).multiply(BigDecimal.valueOf(32)))); }
|
public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testParseExponent() { final Quantity quantity = new QuantityFormatter().parse("1e3"); assertThat(quantity.getFormat(), is(Quantity.Format.DECIMAL_EXPONENT)); assertThat(quantity.getNumber(), is(BigDecimal.valueOf(1000))); }
|
public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testMergePatchPod() throws ApiException { CoreV1Api coreV1Api = new CoreV1Api(client); stubFor( patch(urlPathEqualTo("/api/v1/namespaces/default/pods/foo")) .withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_JSON_MERGE_PATCH)) .willReturn( aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBody("{}"))); PatchUtils.patch( V1Pod.class, () -> coreV1Api.patchNamespacedPodCall( "foo", "default", new V1Patch("[]"), null, null, null, null, null), V1Patch.PATCH_FORMAT_JSON_MERGE_PATCH, client); verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo"))); }
|
public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat); static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat, ApiClient apiClient); }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat); static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat, ApiClient apiClient); }
|
@Test public void testParseNegativeExponent() { final Quantity quantity = new QuantityFormatter().parse("1e-3"); assertThat(quantity.getFormat(), is(Quantity.Format.DECIMAL_EXPONENT)); assertThat(quantity.getNumber(), is(BigDecimal.valueOf(0.001))); }
|
public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test(expected = QuantityFormatException.class) public void testParseBad() { new QuantityFormatter().parse("4e9e"); }
|
public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public Quantity parse(final String value) { if (value == null || value.isEmpty()) { throw new QuantityFormatException(""); } final String[] parts = value.split(PARTS_RE); final BigDecimal numericValue = parseNumericValue(parts[0]); final String suffix = value.substring(parts[0].length()); final BaseExponent baseExponent = new SuffixFormatter().parse(suffix); final BigDecimal unitMultiplier = BigDecimal.valueOf(baseExponent.getBase()) .pow(baseExponent.getExponent(), MathContext.DECIMAL64); final BigDecimal unitlessValue = numericValue.multiply(unitMultiplier); return new Quantity(unitlessValue, baseExponent.getFormat()); } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testFormatPlain() { final String formattedString = new QuantityFormatter() .format(new Quantity(new BigDecimal("100"), Quantity.Format.DECIMAL_SI)); assertThat(formattedString, is("100")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testFormatDecimalSi() { final String formattedString = new QuantityFormatter() .format(new Quantity(new BigDecimal("100000"), Quantity.Format.DECIMAL_SI)); assertThat(formattedString, is("100k")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testFormatFractionalDecimalSi() { final String formattedString = new QuantityFormatter() .format(new Quantity(new BigDecimal("100.001"), Quantity.Format.DECIMAL_SI)); assertThat(formattedString, is("100001m")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testFormatBinarySi() { final String formattedString = new QuantityFormatter() .format(new Quantity(new BigDecimal(2).pow(20), Quantity.Format.BINARY_SI)); assertThat(formattedString, is("1Mi")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testFormatLessThan1024BinarySi() { final String formattedString = new QuantityFormatter() .format(new Quantity(BigDecimal.valueOf(128), Quantity.Format.BINARY_SI)); assertThat(formattedString, is("128")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testFormatNon1024BinarySi() { final String formattedString = new QuantityFormatter() .format(new Quantity(BigDecimal.valueOf(2056), Quantity.Format.BINARY_SI)); assertThat(formattedString, is("2056")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testFormatFractionalBinarySi() { final String formattedString = new QuantityFormatter() .format(new Quantity(BigDecimal.valueOf(123.123), Quantity.Format.BINARY_SI)); assertThat(formattedString, is("123123m")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testFormatDecimalExponent() { final String formattedString = new QuantityFormatter() .format(new Quantity(BigDecimal.valueOf(1000000), Quantity.Format.DECIMAL_EXPONENT)); assertThat(formattedString, is("1e6")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testStrategicMergePatchPod() throws ApiException { CoreV1Api coreV1Api = new CoreV1Api(client); stubFor( patch(urlPathEqualTo("/api/v1/namespaces/default/pods/foo")) .withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH)) .willReturn( aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBody("{}"))); PatchUtils.patch( V1Pod.class, () -> coreV1Api.patchNamespacedPodCall( "foo", "default", new V1Patch("[]"), null, null, null, null, null), V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, client); verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo"))); }
|
public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat); static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat, ApiClient apiClient); }
|
PatchUtils { public static <ApiType> ApiType patch( Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat) throws ApiException { return patch(apiTypeClass, callFunc, patchFormat, Configuration.getDefaultApiClient()); } static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat); static ApiType patch(
Class<ApiType> apiTypeClass, PatchCallFunc callFunc, String patchFormat, ApiClient apiClient); }
|
@Test public void testFormatEnforceExpOf3DecimalExponent() { final String formattedString = new QuantityFormatter() .format(new Quantity(BigDecimal.valueOf(100000), Quantity.Format.DECIMAL_EXPONENT)); assertThat(formattedString, is("100e3")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testFormatNoExpDecimalExponent() { final String formattedString = new QuantityFormatter() .format(new Quantity(BigDecimal.valueOf(12345), Quantity.Format.DECIMAL_EXPONENT)); assertThat(formattedString, is("12345")); }
|
public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
QuantityFormatter { public String format(final Quantity quantity) { switch (quantity.getFormat()) { case DECIMAL_SI: case DECIMAL_EXPONENT: return toBase10String(quantity); case BINARY_SI: if (isFractional(quantity)) { return toBase10String(new Quantity(quantity.getNumber(), Quantity.Format.DECIMAL_SI)); } return toBase1024String(quantity); default: throw new IllegalArgumentException("Can't format a " + quantity.getFormat() + " quantity"); } } Quantity parse(final String value); String format(final Quantity quantity); }
|
@Test public void testParseBinaryKi() { final BaseExponent baseExponent = new SuffixFormatter().parse("Ki"); assertThat(baseExponent.getBase(), is(2)); assertThat(baseExponent.getExponent(), is(10)); assertThat(baseExponent.getFormat(), is(Quantity.Format.BINARY_SI)); }
|
public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testParseDecimalZero() { final BaseExponent baseExponent = new SuffixFormatter().parse(""); assertThat(baseExponent.getBase(), is(10)); assertThat(baseExponent.getExponent(), is(0)); assertThat(baseExponent.getFormat(), is(Quantity.Format.DECIMAL_SI)); }
|
public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testParseDecimalK() { final BaseExponent baseExponent = new SuffixFormatter().parse("k"); assertThat(baseExponent.getBase(), is(10)); assertThat(baseExponent.getExponent(), is(3)); assertThat(baseExponent.getFormat(), is(Quantity.Format.DECIMAL_SI)); }
|
public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testParseDecimalExponent() { final BaseExponent baseExponent = new SuffixFormatter().parse("E2"); assertThat(baseExponent.getBase(), is(10)); assertThat(baseExponent.getExponent(), is(2)); assertThat(baseExponent.getFormat(), is(Quantity.Format.DECIMAL_EXPONENT)); }
|
public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testParseDecimalExponentPositive() { final BaseExponent baseExponent = new SuffixFormatter().parse("e+3"); assertThat(baseExponent.getBase(), is(10)); assertThat(baseExponent.getExponent(), is(3)); assertThat(baseExponent.getFormat(), is(Quantity.Format.DECIMAL_EXPONENT)); }
|
public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testParseDecimalExponentNegative() { final BaseExponent baseExponent = new SuffixFormatter().parse("e-3"); assertThat(baseExponent.getBase(), is(10)); assertThat(baseExponent.getExponent(), is(-3)); assertThat(baseExponent.getFormat(), is(Quantity.Format.DECIMAL_EXPONENT)); }
|
public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test(expected = QuantityFormatException.class) public void testParseBad() { new SuffixFormatter().parse("eKi"); }
|
public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public BaseExponent parse(final String suffix) { final BaseExponent decimalSuffix = suffixToDecimal.get(suffix); if (decimalSuffix != null) { return decimalSuffix; } final BaseExponent binarySuffix = suffixToBinary.get(suffix); if (binarySuffix != null) { return binarySuffix; } if (suffix.length() > 0 && (suffix.charAt(0) == 'E' || suffix.charAt(0) == 'e')) { return extractDecimalExponent(suffix); } throw new QuantityFormatException("Could not parse suffix"); } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testFormatZeroDecimalExponent() { final String formattedString = new SuffixFormatter().format(Quantity.Format.DECIMAL_EXPONENT, 0); assertThat(formattedString, is("")); }
|
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testPrebuiltModelMapping() { assertEquals(V1Pod.class, ModelMapper.getApiTypeClass("", "v1", "Pod")); assertEquals(V1Deployment.class, ModelMapper.getApiTypeClass("", "v1", "Deployment")); assertEquals( V1beta1CustomResourceDefinition.class, ModelMapper.getApiTypeClass("", "v1beta1", "CustomResourceDefinition")); }
|
public static Class<?> getApiTypeClass(String apiGroupVersion, String kind) { String[] parts = apiGroupVersion.split("/"); String apiGroup; String apiVersion; if (parts.length == 1) { apiGroup = ""; apiVersion = apiGroupVersion; } else { apiGroup = parts[0]; apiVersion = parts[1]; } return getApiTypeClass(apiGroup, apiVersion, kind); }
|
ModelMapper { public static Class<?> getApiTypeClass(String apiGroupVersion, String kind) { String[] parts = apiGroupVersion.split("/"); String apiGroup; String apiVersion; if (parts.length == 1) { apiGroup = ""; apiVersion = apiGroupVersion; } else { apiGroup = parts[0]; apiVersion = parts[1]; } return getApiTypeClass(apiGroup, apiVersion, kind); } }
|
ModelMapper { public static Class<?> getApiTypeClass(String apiGroupVersion, String kind) { String[] parts = apiGroupVersion.split("/"); String apiGroup; String apiVersion; if (parts.length == 1) { apiGroup = ""; apiVersion = apiGroupVersion; } else { apiGroup = parts[0]; apiVersion = parts[1]; } return getApiTypeClass(apiGroup, apiVersion, kind); } }
|
ModelMapper { public static Class<?> getApiTypeClass(String apiGroupVersion, String kind) { String[] parts = apiGroupVersion.split("/"); String apiGroup; String apiVersion; if (parts.length == 1) { apiGroup = ""; apiVersion = apiGroupVersion; } else { apiGroup = parts[0]; apiVersion = parts[1]; } return getApiTypeClass(apiGroup, apiVersion, kind); } @Deprecated static void addModelMap(String apiGroupVersion, String kind, Class<?> clazz); @Deprecated static void addModelMap(String group, String version, String kind, Class<?> clazz); static void addModelMap(
String group, String version, String kind, String resourceNamePlural, Class<?> clazz); static void addModelMap(
String group,
String version,
String kind,
String resourceNamePlural,
Boolean isNamespacedResource,
Class<?> clazz); static Class<?> getApiTypeClass(String apiGroupVersion, String kind); static Class<?> getApiTypeClass(String group, String version, String kind); static GroupVersionKind getGroupVersionKindByClass(Class<?> clazz); static GroupVersionResource getGroupVersionResourceByClass(Class<?> clazz); static Set<Discovery.APIResource> refresh(Discovery discovery); static Set<Discovery.APIResource> refresh(Discovery discovery, Duration refreshInterval); static boolean isApiDiscoveryRefreshed(); static Class<?> preBuiltGetApiTypeClass(String group, String version, String kind); static GroupVersionKind preBuiltGetGroupVersionKindByClass(Class<?> clazz); static Boolean isNamespaced(Class<?> clazz); }
|
ModelMapper { public static Class<?> getApiTypeClass(String apiGroupVersion, String kind) { String[] parts = apiGroupVersion.split("/"); String apiGroup; String apiVersion; if (parts.length == 1) { apiGroup = ""; apiVersion = apiGroupVersion; } else { apiGroup = parts[0]; apiVersion = parts[1]; } return getApiTypeClass(apiGroup, apiVersion, kind); } @Deprecated static void addModelMap(String apiGroupVersion, String kind, Class<?> clazz); @Deprecated static void addModelMap(String group, String version, String kind, Class<?> clazz); static void addModelMap(
String group, String version, String kind, String resourceNamePlural, Class<?> clazz); static void addModelMap(
String group,
String version,
String kind,
String resourceNamePlural,
Boolean isNamespacedResource,
Class<?> clazz); static Class<?> getApiTypeClass(String apiGroupVersion, String kind); static Class<?> getApiTypeClass(String group, String version, String kind); static GroupVersionKind getGroupVersionKindByClass(Class<?> clazz); static GroupVersionResource getGroupVersionResourceByClass(Class<?> clazz); static Set<Discovery.APIResource> refresh(Discovery discovery); static Set<Discovery.APIResource> refresh(Discovery discovery, Duration refreshInterval); static boolean isApiDiscoveryRefreshed(); static Class<?> preBuiltGetApiTypeClass(String group, String version, String kind); static GroupVersionKind preBuiltGetGroupVersionKindByClass(Class<?> clazz); static Boolean isNamespaced(Class<?> clazz); static final Duration DEFAULT_DISCOVERY_REFRESH_INTERVAL; }
|
@Test public void testFormatDecimalExponent() { final String formattedString = new SuffixFormatter().format(Quantity.Format.DECIMAL_EXPONENT, 3); assertThat(formattedString, is("e3")); }
|
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testFormatZeroDecimalSi() { final String formattedString = new SuffixFormatter().format(Quantity.Format.DECIMAL_SI, 0); assertThat(formattedString, is("")); }
|
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test(expected = IllegalArgumentException.class) public void testFormatBadDecimalSi() { new SuffixFormatter().format(Quantity.Format.DECIMAL_SI, 2); }
|
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testFormatDecimalSi() { final String formattedString = new SuffixFormatter().format(Quantity.Format.DECIMAL_SI, 3); assertThat(formattedString, is("k")); }
|
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testFormatNegativeDecimalSi() { final String formattedString = new SuffixFormatter().format(Quantity.Format.DECIMAL_SI, -6); assertThat(formattedString, is("u")); }
|
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testFormatBinarySi() { final String formattedString = new SuffixFormatter().format(Quantity.Format.BINARY_SI, 10); assertThat(formattedString, is("Ki")); }
|
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testFormatNoExponentBinarySi() { final String formattedString = new SuffixFormatter().format(Quantity.Format.BINARY_SI, 0); assertThat(formattedString, is("")); }
|
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test(expected = IllegalArgumentException.class) public void testFormatBadBinarySi() { new SuffixFormatter().format(Quantity.Format.BINARY_SI, 4); }
|
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
SuffixFormatter { public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw new IllegalStateException("Can't format " + format + " with exponent " + exponent); } } BaseExponent parse(final String suffix); String format(final Quantity.Format format, final int exponent); }
|
@Test public void testSimpleDelayingQueue() throws Exception { DefaultDelayingQueue<String> queue = new DefaultDelayingQueue<>(); queue.addAfter("foo", Duration.ofMillis(50)); assertTrue(waitForWaitingQueueToFill(queue)); assertTrue(queue.length() == 0); Thread.sleep(60L); assertTrue(waitForAdded(queue, 1)); String item = queue.get(); queue.done(item); Thread.sleep(10 * 1000L); assertTrue(queue.length() == 0); }
|
public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); }
|
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); } }
|
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); } DefaultDelayingQueue(ExecutorService waitingWorker); DefaultDelayingQueue(); }
|
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); } DefaultDelayingQueue(ExecutorService waitingWorker); DefaultDelayingQueue(); void addAfter(T item, Duration duration); }
|
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); } DefaultDelayingQueue(ExecutorService waitingWorker); DefaultDelayingQueue(); void addAfter(T item, Duration duration); static Duration heartBeatInterval; }
|
@Test public void testDeduping() throws Exception { DefaultDelayingQueue<String> queue = new DefaultDelayingQueue<>(); String item = "foo"; queue.addAfter(item, Duration.ofMillis(50)); assertTrue(waitForWaitingQueueToFill(queue)); queue.addAfter(item, Duration.ofMillis(70)); assertTrue(waitForWaitingQueueToFill(queue)); assertTrue("should not have added", queue.length() == 0); Thread.sleep(60L); assertTrue(waitForAdded(queue, 1)); item = queue.get(); queue.done(item); Thread.sleep(20L); assertTrue("should not have added", queue.length() == 0); queue.addAfter(item, Duration.ofMillis(50)); queue.addAfter(item, Duration.ofMillis(30)); assertTrue(waitForWaitingQueueToFill(queue)); assertTrue("should not have added", queue.length() == 0); Thread.sleep(40L); assertTrue(waitForAdded(queue, 1)); item = queue.get(); queue.done(item); Thread.sleep(1L); assertTrue("should not have added", queue.length() == 0); }
|
public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); }
|
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); } }
|
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); } DefaultDelayingQueue(ExecutorService waitingWorker); DefaultDelayingQueue(); }
|
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); } DefaultDelayingQueue(ExecutorService waitingWorker); DefaultDelayingQueue(); void addAfter(T item, Duration duration); }
|
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); } DefaultDelayingQueue(ExecutorService waitingWorker); DefaultDelayingQueue(); void addAfter(T item, Duration duration); static Duration heartBeatInterval; }
|
@Test public void testPreBuiltGetClassByKind() { assertEquals( new GroupVersionKind("", "v1", "Pod"), ModelMapper.preBuiltGetGroupVersionKindByClass(V1Pod.class)); assertEquals( new GroupVersionKind("", "v1", "Pod"), ModelMapper.preBuiltGetGroupVersionKindByClass(V1Pod.class)); assertEquals( new GroupVersionKind("", "v1", "Deployment"), ModelMapper.preBuiltGetGroupVersionKindByClass(V1Deployment.class)); assertEquals( new GroupVersionKind("", "v1beta1", "CustomResourceDefinition"), ModelMapper.preBuiltGetGroupVersionKindByClass(V1beta1CustomResourceDefinition.class)); }
|
public static GroupVersionKind preBuiltGetGroupVersionKindByClass(Class<?> clazz) { return preBuiltClassesByGVK.entrySet().stream() .filter(e -> clazz.equals(e.getValue())) .map(e -> e.getKey()) .findFirst() .get(); }
|
ModelMapper { public static GroupVersionKind preBuiltGetGroupVersionKindByClass(Class<?> clazz) { return preBuiltClassesByGVK.entrySet().stream() .filter(e -> clazz.equals(e.getValue())) .map(e -> e.getKey()) .findFirst() .get(); } }
|
ModelMapper { public static GroupVersionKind preBuiltGetGroupVersionKindByClass(Class<?> clazz) { return preBuiltClassesByGVK.entrySet().stream() .filter(e -> clazz.equals(e.getValue())) .map(e -> e.getKey()) .findFirst() .get(); } }
|
ModelMapper { public static GroupVersionKind preBuiltGetGroupVersionKindByClass(Class<?> clazz) { return preBuiltClassesByGVK.entrySet().stream() .filter(e -> clazz.equals(e.getValue())) .map(e -> e.getKey()) .findFirst() .get(); } @Deprecated static void addModelMap(String apiGroupVersion, String kind, Class<?> clazz); @Deprecated static void addModelMap(String group, String version, String kind, Class<?> clazz); static void addModelMap(
String group, String version, String kind, String resourceNamePlural, Class<?> clazz); static void addModelMap(
String group,
String version,
String kind,
String resourceNamePlural,
Boolean isNamespacedResource,
Class<?> clazz); static Class<?> getApiTypeClass(String apiGroupVersion, String kind); static Class<?> getApiTypeClass(String group, String version, String kind); static GroupVersionKind getGroupVersionKindByClass(Class<?> clazz); static GroupVersionResource getGroupVersionResourceByClass(Class<?> clazz); static Set<Discovery.APIResource> refresh(Discovery discovery); static Set<Discovery.APIResource> refresh(Discovery discovery, Duration refreshInterval); static boolean isApiDiscoveryRefreshed(); static Class<?> preBuiltGetApiTypeClass(String group, String version, String kind); static GroupVersionKind preBuiltGetGroupVersionKindByClass(Class<?> clazz); static Boolean isNamespaced(Class<?> clazz); }
|
ModelMapper { public static GroupVersionKind preBuiltGetGroupVersionKindByClass(Class<?> clazz) { return preBuiltClassesByGVK.entrySet().stream() .filter(e -> clazz.equals(e.getValue())) .map(e -> e.getKey()) .findFirst() .get(); } @Deprecated static void addModelMap(String apiGroupVersion, String kind, Class<?> clazz); @Deprecated static void addModelMap(String group, String version, String kind, Class<?> clazz); static void addModelMap(
String group, String version, String kind, String resourceNamePlural, Class<?> clazz); static void addModelMap(
String group,
String version,
String kind,
String resourceNamePlural,
Boolean isNamespacedResource,
Class<?> clazz); static Class<?> getApiTypeClass(String apiGroupVersion, String kind); static Class<?> getApiTypeClass(String group, String version, String kind); static GroupVersionKind getGroupVersionKindByClass(Class<?> clazz); static GroupVersionResource getGroupVersionResourceByClass(Class<?> clazz); static Set<Discovery.APIResource> refresh(Discovery discovery); static Set<Discovery.APIResource> refresh(Discovery discovery, Duration refreshInterval); static boolean isApiDiscoveryRefreshed(); static Class<?> preBuiltGetApiTypeClass(String group, String version, String kind); static GroupVersionKind preBuiltGetGroupVersionKindByClass(Class<?> clazz); static Boolean isNamespaced(Class<?> clazz); static final Duration DEFAULT_DISCOVERY_REFRESH_INTERVAL; }
|
@Test public void testWrapString() { validateResult( new String[]{"abc", "abcdef", "abcdef"}, StringWrapper.wrapString("abc\nabcdefabcdef", 6, null)); validateResult( new String[]{"abc"}, StringWrapper.wrapString("abc", 6, new String[3])); validateResult( new String[]{"abc"}, StringWrapper.wrapString("abc", 6, new String[0])); validateResult( new String[]{"abc"}, StringWrapper.wrapString("abc", 6, new String[1])); validateResult( new String[]{""}, StringWrapper.wrapString("", 6, new String[3])); validateResult( new String[]{"abcdef"}, StringWrapper.wrapString("abcdef", 6, new String[3])); validateResult( new String[]{"abcdef", "abcdef"}, StringWrapper.wrapString("abcdef\nabcdef", 6, new String[3])); validateResult( new String[]{"abc", "", "def"}, StringWrapper.wrapString("abc\n\ndef", 6, new String[3])); validateResult( new String[]{"", "abcdef"}, StringWrapper.wrapString("\nabcdef", 6, new String[3])); validateResult( new String[]{"", "", "abcdef"}, StringWrapper.wrapString("\n\nabcdef", 6, new String[3])); validateResult( new String[]{"", "", "abcdef"}, StringWrapper.wrapString("\n\nabcdef", 6, new String[4])); validateResult( new String[]{"", "", "abcdef", ""}, StringWrapper.wrapString("\n\nabcdef\n\n", 6, new String[4])); validateResult( new String[]{"", "", "abcdef", "a", ""}, StringWrapper.wrapString("\n\nabcdefa\n\n", 6, new String[4])); validateResult( new String[]{"", "", "abcdef", "a", ""}, StringWrapper.wrapString("\n\nabcdefa\n\n", 6, new String[0])); validateResult( new String[]{"", "", "abcdef", "a", ""}, StringWrapper.wrapString("\n\nabcdefa\n\n", 6, new String[5])); validateResult( new String[]{"", "", "a", "b", "c", "d", "e", "f", "a", ""}, StringWrapper.wrapString("\n\nabcdefa\n\n", 1, new String[5])); }
|
public static String[] wrapString(@Nonnull String str, int maxWidth, @Nullable String[] output) { if (output == null) { output = new String[(int)((str.length() / maxWidth) * 1.5d + 1)]; } int lineStart = 0; int arrayIndex = 0; int i; for (i=0; i<str.length(); i++) { char c = str.charAt(i); if (c == '\n') { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i+1; } else if (i - lineStart == maxWidth) { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i; } } if (lineStart != i || i == 0) { output = addString(output, str.substring(lineStart), arrayIndex++, output.length+1); } if (arrayIndex < output.length) { output[arrayIndex] = null; } return output; }
|
StringWrapper { public static String[] wrapString(@Nonnull String str, int maxWidth, @Nullable String[] output) { if (output == null) { output = new String[(int)((str.length() / maxWidth) * 1.5d + 1)]; } int lineStart = 0; int arrayIndex = 0; int i; for (i=0; i<str.length(); i++) { char c = str.charAt(i); if (c == '\n') { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i+1; } else if (i - lineStart == maxWidth) { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i; } } if (lineStart != i || i == 0) { output = addString(output, str.substring(lineStart), arrayIndex++, output.length+1); } if (arrayIndex < output.length) { output[arrayIndex] = null; } return output; } }
|
StringWrapper { public static String[] wrapString(@Nonnull String str, int maxWidth, @Nullable String[] output) { if (output == null) { output = new String[(int)((str.length() / maxWidth) * 1.5d + 1)]; } int lineStart = 0; int arrayIndex = 0; int i; for (i=0; i<str.length(); i++) { char c = str.charAt(i); if (c == '\n') { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i+1; } else if (i - lineStart == maxWidth) { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i; } } if (lineStart != i || i == 0) { output = addString(output, str.substring(lineStart), arrayIndex++, output.length+1); } if (arrayIndex < output.length) { output[arrayIndex] = null; } return output; } }
|
StringWrapper { public static String[] wrapString(@Nonnull String str, int maxWidth, @Nullable String[] output) { if (output == null) { output = new String[(int)((str.length() / maxWidth) * 1.5d + 1)]; } int lineStart = 0; int arrayIndex = 0; int i; for (i=0; i<str.length(); i++) { char c = str.charAt(i); if (c == '\n') { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i+1; } else if (i - lineStart == maxWidth) { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i; } } if (lineStart != i || i == 0) { output = addString(output, str.substring(lineStart), arrayIndex++, output.length+1); } if (arrayIndex < output.length) { output[arrayIndex] = null; } return output; } static String[] wrapString(@Nonnull String str, int maxWidth, @Nullable String[] output); }
|
StringWrapper { public static String[] wrapString(@Nonnull String str, int maxWidth, @Nullable String[] output) { if (output == null) { output = new String[(int)((str.length() / maxWidth) * 1.5d + 1)]; } int lineStart = 0; int arrayIndex = 0; int i; for (i=0; i<str.length(); i++) { char c = str.charAt(i); if (c == '\n') { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i+1; } else if (i - lineStart == maxWidth) { output = addString(output, str.substring(lineStart, i), arrayIndex++); lineStart = i; } } if (lineStart != i || i == 0) { output = addString(output, str.substring(lineStart), arrayIndex++, output.length+1); } if (arrayIndex < output.length) { output[arrayIndex] = null; } return output; } static String[] wrapString(@Nonnull String str, int maxWidth, @Nullable String[] output); }
|
@Test public void testShortedPathComponent() { StringBuilder sb = new StringBuilder(); for (int i=0; i<300; i++) { sb.append((char)i); } String result = ClassFileNameHandler.shortenPathComponent(sb.toString(), 255); Assert.assertEquals(255, result.length()); }
|
@Nonnull static String shortenPathComponent(@Nonnull String pathComponent, int maxLength) { int toRemove = pathComponent.length() - maxLength + 1; int firstIndex = (pathComponent.length()/2) - (toRemove/2); return pathComponent.substring(0, firstIndex) + "#" + pathComponent.substring(firstIndex+toRemove); }
|
ClassFileNameHandler { @Nonnull static String shortenPathComponent(@Nonnull String pathComponent, int maxLength) { int toRemove = pathComponent.length() - maxLength + 1; int firstIndex = (pathComponent.length()/2) - (toRemove/2); return pathComponent.substring(0, firstIndex) + "#" + pathComponent.substring(firstIndex+toRemove); } }
|
ClassFileNameHandler { @Nonnull static String shortenPathComponent(@Nonnull String pathComponent, int maxLength) { int toRemove = pathComponent.length() - maxLength + 1; int firstIndex = (pathComponent.length()/2) - (toRemove/2); return pathComponent.substring(0, firstIndex) + "#" + pathComponent.substring(firstIndex+toRemove); } ClassFileNameHandler(File path, String fileExtension); }
|
ClassFileNameHandler { @Nonnull static String shortenPathComponent(@Nonnull String pathComponent, int maxLength) { int toRemove = pathComponent.length() - maxLength + 1; int firstIndex = (pathComponent.length()/2) - (toRemove/2); return pathComponent.substring(0, firstIndex) + "#" + pathComponent.substring(firstIndex+toRemove); } ClassFileNameHandler(File path, String fileExtension); File getUniqueFilenameForClass(String className); }
|
ClassFileNameHandler { @Nonnull static String shortenPathComponent(@Nonnull String pathComponent, int maxLength) { int toRemove = pathComponent.length() - maxLength + 1; int firstIndex = (pathComponent.length()/2) - (toRemove/2); return pathComponent.substring(0, firstIndex) + "#" + pathComponent.substring(firstIndex+toRemove); } ClassFileNameHandler(File path, String fileExtension); File getUniqueFilenameForClass(String className); }
|
@Test public void testReadSmallUintSuccess() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {0x11, 0x22, 0x33, 0x44}); Assert.assertEquals(0x44332211, dexBuf.readSmallUint(0)); dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00, 0x00, 0x00}); Assert.assertEquals(0, dexBuf.readSmallUint(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, 0x7f}); Assert.assertEquals(0x7fffffff, dexBuf.readSmallUint(0)); }
|
public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test(expected=ExceptionWithContext.class) public void testReadSmallUintTooLarge1() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00, 0x00, (byte)0x80}); dexBuf.readSmallUint(0); }
|
public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test(expected=ExceptionWithContext.class) public void testReadSmallUintTooLarge2() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0x80}); dexBuf.readSmallUint(0); }
|
public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test(expected=ExceptionWithContext.class) public void testReadSmallUintTooLarge3() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff}); dexBuf.readSmallUint(0); }
|
public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test(expected=ExceptionWithContext.class) public void testReadOptionalUintTooLarge1() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00, 0x00, (byte)0x80}); dexBuf.readSmallUint(0); }
|
public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test(expected=ExceptionWithContext.class) public void testReadOptionalUintTooLarge2() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0x80}); dexBuf.readSmallUint(0); }
|
public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test(expected=ExceptionWithContext.class) public void testReadOptionalUintTooLarge3() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {(byte)0xfe, (byte)0xff, (byte)0xff, (byte)0xff}); dexBuf.readSmallUint(0); }
|
public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readSmallUint(int offset) { byte[] buf = this.buf; int result = (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3]) << 24); if (result < 0) { throw new ExceptionWithContext("Encountered small uint that is out of range at offset 0x%x", offset); } return result; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test public void testReadUshort() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {0x11, 0x22}); Assert.assertEquals(dexBuf.readUshort(0), 0x2211); dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00}); Assert.assertEquals(dexBuf.readUshort(0), 0); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff}); Assert.assertEquals(dexBuf.readUshort(0), 0xffff); dexBuf = new BaseDexBuffer(new byte[] {(byte)0x00, (byte)0x80}); Assert.assertEquals(dexBuf.readUshort(0), 0x8000); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0x7f}); Assert.assertEquals(dexBuf.readUshort(0), 0x7fff); }
|
public int readUshort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8); }
|
BaseDexBuffer { public int readUshort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8); } }
|
BaseDexBuffer { public int readUshort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8); } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readUshort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readUshort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test public void testReadUbyte() { byte[] buf = new byte[1]; BaseDexBuffer dexBuf = new BaseDexBuffer(buf); for (int i=0; i<=0xff; i++) { buf[0] = (byte)i; Assert.assertEquals(i, dexBuf.readUbyte(0)); } }
|
public int readUbyte(int offset) { return buf[offset] & 0xff; }
|
BaseDexBuffer { public int readUbyte(int offset) { return buf[offset] & 0xff; } }
|
BaseDexBuffer { public int readUbyte(int offset) { return buf[offset] & 0xff; } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readUbyte(int offset) { return buf[offset] & 0xff; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readUbyte(int offset) { return buf[offset] & 0xff; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test public void testReadLong() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}); Assert.assertEquals(0x7766554433221100L, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); Assert.assertEquals(0, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, 0x7f}); Assert.assertEquals(Long.MAX_VALUE, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0x80}); Assert.assertEquals(Long.MIN_VALUE, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x80}); Assert.assertEquals(0x80ffffffffffffffL, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff}); Assert.assertEquals(-1, dexBuf.readLong(0)); }
|
public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); }
|
BaseDexBuffer { public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); } }
|
BaseDexBuffer { public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test public void testReadInt() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {0x11, 0x22, 0x33, 0x44}); Assert.assertEquals(0x44332211, dexBuf.readInt(0)); dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00, 0x00, 0x00}); Assert.assertEquals(0, dexBuf.readInt(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, 0x7f}); Assert.assertEquals(Integer.MAX_VALUE, dexBuf.readInt(0)); dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00, 0x00, (byte)0x80}); Assert.assertEquals(Integer.MIN_VALUE, dexBuf.readInt(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0x80}); Assert.assertEquals(0x80ffffff, dexBuf.readInt(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff}); Assert.assertEquals(-1, dexBuf.readInt(0)); }
|
public int readInt(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | (buf[offset+3] << 24); }
|
BaseDexBuffer { public int readInt(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | (buf[offset+3] << 24); } }
|
BaseDexBuffer { public int readInt(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | (buf[offset+3] << 24); } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readInt(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | (buf[offset+3] << 24); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readInt(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | (buf[offset+3] << 24); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test public void testReadShort() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {0x11, 0x22}); Assert.assertEquals(dexBuf.readShort(0), 0x2211); dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00}); Assert.assertEquals(dexBuf.readShort(0), 0); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff}); Assert.assertEquals(dexBuf.readShort(0), -1); dexBuf = new BaseDexBuffer(new byte[] {(byte)0x00, (byte)0x80}); Assert.assertEquals(dexBuf.readShort(0), Short.MIN_VALUE); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0x7f}); Assert.assertEquals(dexBuf.readShort(0), 0x7fff); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0x80}); Assert.assertEquals(dexBuf.readShort(0), 0xffff80ff); }
|
public int readShort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | (buf[offset+1] << 8); }
|
BaseDexBuffer { public int readShort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | (buf[offset+1] << 8); } }
|
BaseDexBuffer { public int readShort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | (buf[offset+1] << 8); } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readShort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | (buf[offset+1] << 8); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readShort(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | (buf[offset+1] << 8); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test public void testReadByte() { byte[] buf = new byte[1]; BaseDexBuffer dexBuf = new BaseDexBuffer(buf); for (int i=0; i<=0xff; i++) { buf[0] = (byte)i; Assert.assertEquals((byte)i, dexBuf.readByte(0)); } }
|
public int readByte(int offset) { return buf[offset]; }
|
BaseDexBuffer { public int readByte(int offset) { return buf[offset]; } }
|
BaseDexBuffer { public int readByte(int offset) { return buf[offset]; } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public int readByte(int offset) { return buf[offset]; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public int readByte(int offset) { return buf[offset]; } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test public void testReadLongRandom() { Random r = new Random(1234567890); ByteBuffer byteBuf = ByteBuffer.allocateDirect(8).order(ByteOrder.LITTLE_ENDIAN); byte[] buf = new byte[8]; BaseDexBuffer dexBuf = new BaseDexBuffer(buf); for (int i=0; i<10000; i++) { int val = r.nextInt(); byteBuf.putLong(0, val); byteBuf.position(0); byteBuf.get(buf); Assert.assertEquals(val, dexBuf.readLong(0)); } }
|
public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); }
|
BaseDexBuffer { public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); } }
|
BaseDexBuffer { public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); } BaseDexBuffer(@Nonnull byte[] buf); }
|
BaseDexBuffer { public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
BaseDexBuffer { public long readLong(int offset) { byte[] buf = this.buf; return (buf[offset] & 0xff) | ((buf[offset+1] & 0xff) << 8) | ((buf[offset+2] & 0xff) << 16) | ((buf[offset+3] & 0xffL) << 24) | ((buf[offset+4] & 0xffL) << 32) | ((buf[offset+5] & 0xffL) << 40) | ((buf[offset+6] & 0xffL) << 48) | (((long)buf[offset+7]) << 56); } BaseDexBuffer(@Nonnull byte[] buf); int readSmallUint(int offset); int readOptionalUint(int offset); int readUshort(int offset); int readUbyte(int offset); long readLong(int offset); int readInt(int offset); int readShort(int offset); int readByte(int offset); @Nonnull BaseDexReader readerAt(int offset); }
|
@Test public void testSettingsMatching() { assertEquals( "@42@bee", new GenerateConfigMojo().getSettingsForArtifact( "cheese:ham@1@nope,foo:bar@42@bee,fuel:oil@1@xx", "foo", "bar" ) ); assertEquals( "", new GenerateConfigMojo().getSettingsForArtifact( "cheese:ham@1@nope,foo:bar@42@bee,fuel:oil@1@xx", "xx", "bb" ) ); assertEquals( "", new GenerateConfigMojo().getSettingsForArtifact( "cheese:ham@1@nope,foo:bar@42@bee,fuel:oil@1@xx", "cheese", "bb" ) ); assertEquals( "@42@bee", new GenerateConfigMojo().getSettingsForArtifact( "cheese:ham@1@nope,foo:bar@42@bee,fuel:oil@1@xx", "foo", "bar" ) ); assertEquals( "", new GenerateConfigMojo().getSettingsForArtifact( "cheese:ham@1@nope,foo:bar@42@bee,fuel:oil@1@xx,ping:back", "ping", "back" ) ); }
|
public String getSettingsForArtifact( String fullSettings, String groupId, String artifactId ) { if( fullSettings != null ) { for( String token : fullSettings.split( "," ) ) { int end = ( token.indexOf( "@" ) >= 0 ) ? token.indexOf( "@" ) : token.length(); String ga_part[] = token.substring( 0, end ).split( ":" ); if( ga_part[ 0 ].equals( groupId ) && ga_part[ 1 ].equals( artifactId ) ) { return token.substring( end ); } } } return ""; }
|
GenerateConfigMojo extends AbstractMojo { public String getSettingsForArtifact( String fullSettings, String groupId, String artifactId ) { if( fullSettings != null ) { for( String token : fullSettings.split( "," ) ) { int end = ( token.indexOf( "@" ) >= 0 ) ? token.indexOf( "@" ) : token.length(); String ga_part[] = token.substring( 0, end ).split( ":" ); if( ga_part[ 0 ].equals( groupId ) && ga_part[ 1 ].equals( artifactId ) ) { return token.substring( end ); } } } return ""; } }
|
GenerateConfigMojo extends AbstractMojo { public String getSettingsForArtifact( String fullSettings, String groupId, String artifactId ) { if( fullSettings != null ) { for( String token : fullSettings.split( "," ) ) { int end = ( token.indexOf( "@" ) >= 0 ) ? token.indexOf( "@" ) : token.length(); String ga_part[] = token.substring( 0, end ).split( ":" ); if( ga_part[ 0 ].equals( groupId ) && ga_part[ 1 ].equals( artifactId ) ) { return token.substring( end ); } } } return ""; } }
|
GenerateConfigMojo extends AbstractMojo { public String getSettingsForArtifact( String fullSettings, String groupId, String artifactId ) { if( fullSettings != null ) { for( String token : fullSettings.split( "," ) ) { int end = ( token.indexOf( "@" ) >= 0 ) ? token.indexOf( "@" ) : token.length(); String ga_part[] = token.substring( 0, end ).split( ":" ); if( ga_part[ 0 ].equals( groupId ) && ga_part[ 1 ].equals( artifactId ) ) { return token.substring( end ); } } } return ""; } void execute(); String getSettingsForArtifact( String fullSettings, String groupId, String artifactId ); }
|
GenerateConfigMojo extends AbstractMojo { public String getSettingsForArtifact( String fullSettings, String groupId, String artifactId ) { if( fullSettings != null ) { for( String token : fullSettings.split( "," ) ) { int end = ( token.indexOf( "@" ) >= 0 ) ? token.indexOf( "@" ) : token.length(); String ga_part[] = token.substring( 0, end ).split( ":" ); if( ga_part[ 0 ].equals( groupId ) && ga_part[ 1 ].equals( artifactId ) ) { return token.substring( end ); } } } return ""; } void execute(); String getSettingsForArtifact( String fullSettings, String groupId, String artifactId ); }
|
@Test public void urlAsReferenceViaFactoryMethod() { assertThat( "Scan composite url", scanComposite( url( "file:foo.composite" ) ).getURL(), is( equalTo( "scan-composite:file:foo.composite@update" ) ) ); }
|
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } CompositeScannerProvisionOption( final String url ); CompositeScannerProvisionOption( final UrlReference url ); }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } CompositeScannerProvisionOption( final String url ); CompositeScannerProvisionOption( final UrlReference url ); String getURL(); }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } CompositeScannerProvisionOption( final String url ); CompositeScannerProvisionOption( final UrlReference url ); String getURL(); }
|
@Test public void urlAsMavenUrl() { assertThat( "Scan composite url", new CompositeScannerProvisionOption( maven().groupId( "bar" ).artifactId( "foo" ).type( "composite" ) ).getURL(), is( equalTo( "scan-composite:mvn:bar/foo ); }
|
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } CompositeScannerProvisionOption( final String url ); CompositeScannerProvisionOption( final UrlReference url ); }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } CompositeScannerProvisionOption( final String url ); CompositeScannerProvisionOption( final UrlReference url ); String getURL(); }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } CompositeScannerProvisionOption( final String url ); CompositeScannerProvisionOption( final UrlReference url ); String getURL(); }
|
@Test public void urlAsMavenUrlViaFactoryMethod() { assertThat( "Scan composite url", scanComposite( maven().groupId( "bar" ).artifactId( "foo" ).type( "composite" ) ).getURL(), is( equalTo( "scan-composite:mvn:bar/foo ); }
|
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } CompositeScannerProvisionOption( final String url ); CompositeScannerProvisionOption( final UrlReference url ); }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } CompositeScannerProvisionOption( final String url ); CompositeScannerProvisionOption( final UrlReference url ); String getURL(); }
|
CompositeScannerProvisionOption extends AbstractUrlProvisionOption<CompositeScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } CompositeScannerProvisionOption( final String url ); CompositeScannerProvisionOption( final UrlReference url ); String getURL(); }
|
@Test public void urlAsString() { assertThat( "Scan file url", new FileScannerProvisionOption( "file:foo.bundles" ).getURL(), is( equalTo( "scan-file:file:foo.bundles" ) ) ); }
|
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
@Test public void urlAsStringViaFactoryMethod() { assertThat( "Scan file url", scanFile( "file:foo.bundles" ).getURL(), is( equalTo( "scan-file:file:foo.bundles" ) ) ); }
|
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
@Test public void urlAsReference() { assertThat( "Scan file url", new FileScannerProvisionOption( url( "file:foo.bundles" ) ).getURL(), is( equalTo( "scan-file:file:foo.bundles" ) ) ); }
|
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
@Test public void urlAsReferenceViaFactoryMethod() { assertThat( "Scan file url", scanFile( url( "file:foo.bundles" ) ).getURL(), is( equalTo( "scan-file:file:foo.bundles" ) ) ); }
|
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
@Test public void urlAsMavenUrl() { assertThat( "Scan file url", new FileScannerProvisionOption( maven().groupId( "bar" ).artifactId( "foo" ).type( "bundles" ) ).getURL(), is( equalTo( "scan-file:mvn:bar/foo ); }
|
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
@Test public void urlAsMavenUrlViaFactoryMethod() { assertThat( "Scan file url", scanFile( maven().groupId( "bar" ).artifactId( "foo" ).type( "bundles" ) ).getURL(), is( equalTo( "scan-file:mvn:bar/foo ); }
|
public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
FileScannerProvisionOption extends AbstractUrlProvisionOption<FileScannerProvisionOption> implements Scanner { public String getURL() { return new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( getOptions( this ) ) .toString(); } FileScannerProvisionOption( final String url ); FileScannerProvisionOption( final UrlReference url ); String getURL(); }
|
@Test public void urlAsString() { assertThat( "Scan features url", new FeaturesScannerProvisionOption( "file:foo-features.xml", "f1", "f2/1.0.0" ).getURL(), is( equalTo( "scan-features:file:foo-features.xml!/f1,f2/1.0.0" ) ) ); }
|
public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); String getURL(); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); String getURL(); }
|
@Test public void urlAsStringViaFactoryMethod() { assertThat( "Scan features url", scanFeatures( "file:foo-features.xml", "f1", "f2/1.0.0" ).getURL(), is( equalTo( "scan-features:file:foo-features.xml!/f1,f2/1.0.0" ) ) ); }
|
public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); String getURL(); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); String getURL(); }
|
@Test public void urlAsReference() { assertThat( "Scan features url", new FeaturesScannerProvisionOption( url( "file:foo-features.xml" ), "f1", "f2/1.0.0" ).getURL(), is( equalTo( "scan-features:file:foo-features.xml!/f1,f2/1.0.0" ) ) ); }
|
public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); String getURL(); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); String getURL(); }
|
@Test public void urlAsReferenceViaFactoryMethod() { assertThat( "Scan features url", scanFeatures( url( "file:foo-features.xml" ), "f1", "f2/1.0.0" ).getURL(), is( equalTo( "scan-features:file:foo-features.xml!/f1,f2/1.0.0" ) ) ); }
|
public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); String getURL(); }
|
FeaturesScannerProvisionOption extends AbstractUrlProvisionOption<FeaturesScannerProvisionOption> implements Scanner { public String getURL() { final StringBuilder url = new StringBuilder() .append( SCHEMA ) .append( SEPARATOR_SCHEME ) .append( super.getURL() ) .append( SEPARATOR_FILTER ); boolean first = true; for( String feature : m_features ) { if( !first ) { url.append( FEATURE_SEPARATOR ); } first = false; url.append( feature ); } url.append( getOptions( this ) ); return url.toString(); } FeaturesScannerProvisionOption( final String repositoryUrl,
final String... features ); FeaturesScannerProvisionOption( final UrlReference repositoryUrl,
final String... features ); String getURL(); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.