Skip to content

Commit 8e890d3

Browse files
Add new wrapper for notebook repo PLUS settings
1 parent 53346d7 commit 8e890d3

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.zeppelin.notebook.repo;
18+
19+
import java.util.Collections;
20+
import java.util.List;
21+
22+
import org.apache.commons.lang.StringUtils;
23+
24+
/**
25+
* Representation of a notebook repo with settings.
26+
* This is mostly a Wrapper around notebook repo information plus settings.
27+
*/
28+
public class NotebookRepoWithSettings {
29+
30+
public static final NotebookRepoWithSettings EMPTY = NotebookRepoWithSettings
31+
.builder(StringUtils.EMPTY)
32+
.build();
33+
34+
public String name;
35+
public String className;
36+
public List<NotebookRepoSettings> settings;
37+
38+
private NotebookRepoWithSettings() {}
39+
40+
public static Builder builder(String name) {
41+
return new Builder(name);
42+
}
43+
44+
private NotebookRepoWithSettings(Builder builder) {
45+
name = builder.name;
46+
className = builder.className;
47+
settings = builder.settings;
48+
}
49+
50+
public boolean isEmpty() {
51+
return this.equals(EMPTY);
52+
}
53+
54+
/**
55+
* Simple builder :).
56+
*/
57+
public static class Builder {
58+
private final String name;
59+
private String className = StringUtils.EMPTY;
60+
private List<NotebookRepoSettings> settings = Collections.emptyList();
61+
62+
public Builder(String name) {
63+
this.name = name;
64+
}
65+
66+
public NotebookRepoWithSettings build() {
67+
return new NotebookRepoWithSettings(this);
68+
}
69+
70+
public Builder className(String className) {
71+
this.className = className;
72+
return this;
73+
}
74+
75+
public Builder settings(List<NotebookRepoSettings> settings) {
76+
this.settings = settings;
77+
return this;
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)