Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NamespaceMapper #388

Closed
wants to merge 12 commits into from
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -16,3 +16,4 @@ build/

# Marquez configuration
config.yml
/.metadata/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to define a .gitignore_global to ignore files specific to your dev environment. The .gitignore in this repo serves as excluding files specific to the project.

1 change: 1 addition & 0 deletions src/main/java/marquez/api/mappers/NamespaceApiMapper.java
Expand Up @@ -21,6 +21,7 @@
import marquez.service.models.Namespace;

public class NamespaceApiMapper extends Mapper<NamespaceResponse, Namespace> {

public Namespace map(NamespaceResponse namespace) {
requireNonNull(namespace, "namespace must not be null");
return new Namespace(
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/marquez/api/mappers/NamespaceMapper.java
@@ -0,0 +1,34 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package marquez.api.mappers;

import static java.util.Objects.requireNonNull;
DavidLi119 marked this conversation as resolved.
Show resolved Hide resolved
import lombok.NonNull;
import marquez.api.models.NamespaceRequest;
import marquez.api.models.NamespaceResponse;
import marquez.service.models.Namespace;
import marquez.common.models.NamespaceName;

public final class NamespaceMapper {
private NamespaceMapper() {}

public static Namespace map(@NonNull NamespaceName namespaceName, @NonNull NamespaceRequest request) {
return new Namespace(
namespaceName,
request.getOwner(),
request.getDescription().orElse(null)
);
}
}
8 changes: 8 additions & 0 deletions src/main/java/marquez/service/models/Namespace.java
Expand Up @@ -17,6 +17,7 @@
import java.sql.Timestamp;
import java.util.UUID;
import lombok.Data;
import marquez.common.models.NamespaceName;

DavidLi119 marked this conversation as resolved.
Show resolved Hide resolved
@Data
public class Namespace {
Expand All @@ -43,4 +44,11 @@ public Namespace(
this.ownerName = ownerName;
this.description = description;
}

public Namespace(
String name, String ownerName, String description) {
this.name = name;
DavidLi119 marked this conversation as resolved.
Show resolved Hide resolved
this.ownerName = ownerName;
this.description = description;
}
}