Skip to content

Commit

Permalink
Added Schema 'toString' methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
vnayar committed Apr 28, 2022
1 parent 9bfe4ed commit 3e0c58c
Show file tree
Hide file tree
Showing 5 changed files with 265 additions and 10 deletions.
5 changes: 5 additions & 0 deletions source/avro/attributes.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ mixin template HasJsonAttributes() {
const(OrderedMap!(string, JSONValue)) getAttributes() const {
return attributes;
}

/// Returns true if there is at least one attribute.
bool hasAttributes() const {
return !attributes.isEmpty();
}
}

///
Expand Down
6 changes: 3 additions & 3 deletions source/avro/field.d
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ public class Field {
return defaultValue;
}

public Order getOrder() {
public Order getOrder() const {
return order;
}

public void addAlias(string name) {
aliases[name] = true;
}

public bool[string] getAliases() {
return aliases;
public string[] getAliases() const {
return aliases.keys;
}
}
5 changes: 5 additions & 0 deletions source/avro/orderedmap.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ struct OrderedMap(KeyT, ValueT) {
return value;
}

/// Returns whether the OrderedMap is empty or not.
bool isEmpty() const {
return orderedKeys.length == 0;
}

/// Removes a single item from the map and the orderedKeys.
void remove(KeyT key) {
import std.algorithm : remove;
Expand Down
Loading

0 comments on commit 3e0c58c

Please sign in to comment.