Skip to content

Commit

Permalink
Consistent naming of baseTimeUnit(), type() (fixes #219)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Nov 16, 2017
1 parent 67f247c commit 9d6f177
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ default Iterable<Measurement> measure() {
}

@Override
default Type getType() {
default Type type() {
return Type.Counter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ default Iterable<Measurement> measure() {
}

@Override
default Meter.Type getType() {
default Meter.Type type() {
return Meter.Type.Counter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ default Iterable<Measurement> measure() {
}

@Override
default Type getType() {
default Type type() {
return Type.Gauge;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ default Iterable<Measurement> measure() {
}

@Override
default Type getType() {
default Type type() {
return Type.LongTaskTimer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface Meter {
*/
Iterable<Measurement> measure();

default Type getType() {
default Type type() {
return Type.Other;
}

Expand All @@ -63,11 +63,6 @@ class Id {
private final List<Tag> tags;
private String baseUnit;
private final String description;

/**
* Set after this id has been bound to a specific meter, effectively precluding it from use by a meter of a
* different type.
*/
private Type type;

public Id(String name, Iterable<Tag> tags, String baseUnit, String description, Type type) {
Expand Down Expand Up @@ -144,15 +139,6 @@ public int hashCode() {
return Objects.hash(name, tags);
}

/**
* Associate this id with a specific type, sometimes used in the determination of a
* convention name. This association is 1-1 since an id can only be used once per registry
* across all types.
*/
public void setType(Meter.Type type) {
this.type = type;
}

public Type getType() {
return type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public double value() {
}

@Override
public TimeUnit getBaseTimeUnit() {
public TimeUnit baseTimeUnit() {
return baseTimeUnit;
}
};
Expand Down Expand Up @@ -162,7 +162,7 @@ public Id getId() {
}

@Override
public Type getType() {
public Type type() {
return type;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
* @author Jon Schneider
*/
public interface TimeGauge extends Gauge {
TimeUnit getBaseTimeUnit();
TimeUnit baseTimeUnit();

default double value(TimeUnit unit) {
return TimeUtils.convert(value(), getBaseTimeUnit(), unit);
return TimeUtils.convert(value(), baseTimeUnit(), unit);
}

static <T> Builder<T> builder(String name, T obj, TimeUnit fUnits, ToDoubleFunction<T> f) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ default Iterable<Measurement> measure() {
}

@Override
default Type getType() {
default Type type() {
return Type.Timer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public double value() {
}

@Override
public TimeUnit getBaseTimeUnit() {
return firstChild().getBaseTimeUnit();
public TimeUnit baseTimeUnit() {
return firstChild().baseTimeUnit();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public TimeUnit baseTimeUnit() {
return this.baseTimeUnit;
}

public Type getType() {
public Type type() {
return Type.Timer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public NoopTimeGauge(Id id) {
}

@Override
public TimeUnit getBaseTimeUnit() {
public TimeUnit baseTimeUnit() {
return TimeUnit.NANOSECONDS;
}

Expand Down

0 comments on commit 9d6f177

Please sign in to comment.