Skip to content

Commit

Permalink
Reformat with 4 spaces indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jun 15, 2017
1 parent cc1c611 commit a46b004
Show file tree
Hide file tree
Showing 17 changed files with 1,423 additions and 1,466 deletions.
3 changes: 2 additions & 1 deletion style/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
http://www.opensource.org/licenses/bsd-license.php
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down
128 changes: 63 additions & 65 deletions style/src/main/java/org/jline/style/MemoryStyleSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
*/
package org.jline.style;

import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.annotation.Nullable;

import static java.util.Objects.requireNonNull;

/**
Expand All @@ -24,82 +23,81 @@
* @since 3.4
*/
public class MemoryStyleSource
implements StyleSource
{
private static final Logger log = Logger.getLogger(MemoryStyleSource.class.getName());
implements StyleSource {
private static final Logger log = Logger.getLogger(MemoryStyleSource.class.getName());

private final Map<String,Map<String,String>> backing = new ConcurrentHashMap<>();
private final Map<String, Map<String, String>> backing = new ConcurrentHashMap<>();

@Nullable
@Override
public String get(final String group, final String name) {
String style = null;
Map<String,String> styles = backing.get(group);
if (styles != null) {
style = styles.get(name);
}
@Nullable
@Override
public String get(final String group, final String name) {
String style = null;
Map<String, String> styles = backing.get(group);
if (styles != null) {
style = styles.get(name);
}

if (log.isLoggable(Level.FINEST)) {
log.finest(String.format("Get: [%s] %s -> %s", group, name, style));
}
if (log.isLoggable(Level.FINEST)) {
log.finest(String.format("Get: [%s] %s -> %s", group, name, style));
}

return style;
}
return style;
}

@Override
public void set(final String group, final String name, final String style) {
requireNonNull(group);
requireNonNull(name);
requireNonNull(style);
backing.computeIfAbsent(group, k -> new ConcurrentHashMap<>()).put(name, style);
@Override
public void set(final String group, final String name, final String style) {
requireNonNull(group);
requireNonNull(name);
requireNonNull(style);
backing.computeIfAbsent(group, k -> new ConcurrentHashMap<>()).put(name, style);

if (log.isLoggable(Level.FINEST)) {
log.finest(String.format("Set: [%s] %s -> %s", group, name, style));
if (log.isLoggable(Level.FINEST)) {
log.finest(String.format("Set: [%s] %s -> %s", group, name, style));
}
}
}

@Override
public void remove(final String group) {
requireNonNull(group);
if (backing.remove(group) != null) {
if (log.isLoggable(Level.FINEST)) {
log.finest(String.format("Removed: [%s]", group));
}
@Override
public void remove(final String group) {
requireNonNull(group);
if (backing.remove(group) != null) {
if (log.isLoggable(Level.FINEST)) {
log.finest(String.format("Removed: [%s]", group));
}
}
}
}

@Override
public void remove(final String group, final String name) {
requireNonNull(group);
requireNonNull(name);
Map<String,String> styles = backing.get(group);
if (styles != null) {
styles.remove(name);

if (log.isLoggable(Level.FINEST)) {
log.finest(String.format("Removed: [%s] %s", group, name));
}
@Override
public void remove(final String group, final String name) {
requireNonNull(group);
requireNonNull(name);
Map<String, String> styles = backing.get(group);
if (styles != null) {
styles.remove(name);

if (log.isLoggable(Level.FINEST)) {
log.finest(String.format("Removed: [%s] %s", group, name));
}
}
}
}

@Override
public void clear() {
backing.clear();
log.finest("Cleared");
}
@Override
public void clear() {
backing.clear();
log.finest("Cleared");
}

@Override
public Iterable<String> groups() {
return Collections.unmodifiableSet(backing.keySet());
}
@Override
public Iterable<String> groups() {
return Collections.unmodifiableSet(backing.keySet());
}

@Override
public Map<String,String> styles(final String group) {
requireNonNull(group);
Map<String,String> result = backing.get(group);
if (result == null) {
result = Collections.emptyMap();
@Override
public Map<String, String> styles(final String group) {
requireNonNull(group);
Map<String, String> result = backing.get(group);
if (result == null) {
result = Collections.emptyMap();
}
return Collections.unmodifiableMap(result);
}
return Collections.unmodifiableMap(result);
}
}
118 changes: 58 additions & 60 deletions style/src/main/java/org/jline/style/NopStyleSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
*/
package org.jline.style;

import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Map;

import javax.annotation.Nullable;

import static java.util.Objects.requireNonNull;

/**
Expand All @@ -21,69 +20,68 @@
* @since 3.4
*/
public class NopStyleSource
implements StyleSource
{
// NOTE: preconditions here to help validate usage when this impl is used
implements StyleSource {
// NOTE: preconditions here to help validate usage when this impl is used

/**
* Always returns {@code null}.
*/
@Nullable
@Override
public String get(final String group, final String name) {
requireNonNull(group);
requireNonNull(name);
return null;
}
/**
* Always returns {@code null}.
*/
@Nullable
@Override
public String get(final String group, final String name) {
requireNonNull(group);
requireNonNull(name);
return null;
}

/**
* Non-operation.
*/
@Override
public void set(final String group, final String name, final String style) {
requireNonNull(group);
requireNonNull(name);
requireNonNull(style);
}
/**
* Non-operation.
*/
@Override
public void set(final String group, final String name, final String style) {
requireNonNull(group);
requireNonNull(name);
requireNonNull(style);
}

/**
* Non-operation.
*/
@Override
public void remove(final String group) {
requireNonNull(group);
}
/**
* Non-operation.
*/
@Override
public void remove(final String group) {
requireNonNull(group);
}

/**
* Non-operation.
*/
@Override
public void remove(final String group, final String name) {
requireNonNull(group);
requireNonNull(name);
}
/**
* Non-operation.
*/
@Override
public void remove(final String group, final String name) {
requireNonNull(group);
requireNonNull(name);
}

/**
* Non-operation.
*/
@Override
public void clear() {
// empty
}
/**
* Non-operation.
*/
@Override
public void clear() {
// empty
}

/**
* Always returns empty list.
*/
@Override
public Iterable<String> groups() {
return Collections.unmodifiableList(Collections.emptyList());
}
/**
* Always returns empty list.
*/
@Override
public Iterable<String> groups() {
return Collections.unmodifiableList(Collections.emptyList());
}

/**
* Always returns empty map.
*/
@Override
public Map<String, String> styles(final String group) {
return Collections.unmodifiableMap(Collections.emptyMap());
}
/**
* Always returns empty map.
*/
@Override
public Map<String, String> styles(final String group) {
return Collections.unmodifiableMap(Collections.emptyMap());
}
}
64 changes: 30 additions & 34 deletions style/src/main/java/org/jline/style/StyleBundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,36 @@
*
* @since 3.4
*/
public interface StyleBundle
{
/**
* Provides the style group-name.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@interface StyleGroup
{
String value();
}
public interface StyleBundle {
/**
* Provides the style group-name.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@interface StyleGroup {
String value();
}

/**
* Allows overriding the style-name.
*
* Default style-name is determined from method-name.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
@interface StyleName
{
String value();
}
/**
* Allows overriding the style-name.
* <p>
* Default style-name is determined from method-name.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
@interface StyleName {
String value();
}

/**
* Provide default style-specification.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
@interface DefaultStyle
{
String value();
}
/**
* Provide default style-specification.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
@interface DefaultStyle {
String value();
}
}

0 comments on commit a46b004

Please sign in to comment.