-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start of implementation of Avsc writing for AvroSchema class (#300)
Co-authored-by: Radai Rosenblatt <[email protected]>
- Loading branch information
1 parent
162d032
commit 144d4a0
Showing
31 changed files
with
1,133 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
parser/src/main/java/com/linkedin/avroutil1/model/AvroName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright 2022 LinkedIn Corp. | ||
* Licensed under the BSD 2-Clause License (the "License"). | ||
* See License in the project root for license information. | ||
*/ | ||
|
||
package com.linkedin.avroutil1.model; | ||
|
||
import java.util.Objects; | ||
|
||
|
||
public class AvroName { | ||
private final static String NO_NAMESPACE = ""; | ||
|
||
private final String simpleName; | ||
private final String namespace; | ||
private final String fullname; | ||
|
||
public AvroName(String simpleName, String namespace) { | ||
if (simpleName == null || simpleName.isEmpty()) { | ||
throw new IllegalArgumentException("simple name required"); | ||
} | ||
if (simpleName.contains(".")) { | ||
throw new IllegalArgumentException("simple name must be simple: " + simpleName); | ||
} | ||
this.simpleName = simpleName; | ||
if (namespace != null && !namespace.isEmpty()) { | ||
this.namespace = namespace; | ||
this.fullname = namespace + "." + simpleName; | ||
} else { | ||
this.namespace = NO_NAMESPACE; | ||
this.fullname = this.simpleName; | ||
} | ||
} | ||
|
||
public String getSimpleName() { | ||
return simpleName; | ||
} | ||
|
||
public String getNamespace() { | ||
return namespace; | ||
} | ||
|
||
public String getFullname() { | ||
return fullname; | ||
} | ||
|
||
public boolean hasNamespace() { | ||
return !NO_NAMESPACE.equals(namespace); | ||
} | ||
|
||
public String qualified(String contextNamespace) { | ||
if (!namespace.equals(contextNamespace)) { //also works if argument is null | ||
return fullname; | ||
} | ||
return simpleName; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return fullname; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
AvroName avroName = (AvroName) o; | ||
return Objects.equals(fullname, avroName.fullname); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(fullname); | ||
} | ||
} |
Oops, something went wrong.