BrightSide Workbench Full Report + Source Code
AxMemberPreferences.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2023 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.server.db.entities;
20 
21 import java.io.Serializable;
22 import java.util.Map;
23 import javax.json.JsonValue;
24 import javax.persistence.Entity;
25 import javax.persistence.Id;
26 import org.turro.jpa.entity.IDaoEntity;
27 import org.turro.json.IJSONizable;
28 import org.turro.ws.WsMember;
29 import org.turro.ws.service.server.Clients;
30 
35 @Entity
36 public class AxMemberPreferences implements Serializable, IDaoEntity, IJSONizable {
37 
38  @Id Long memberId;
39 
40  private boolean defaultBan;
41 
42  public Long getMemberId() {
43  return memberId;
44  }
45 
46  public void setMemberId(Long memberId) {
47  this.memberId = memberId;
48  }
49 
50  public boolean isDefaultBan() {
51  return defaultBan;
52  }
53 
54  public void setDefaultBan(boolean defaultBan) {
55  this.defaultBan = defaultBan;
56  }
57 
58  /* Member */
59 
60  public WsMember getMember() {
61  return Clients.getMember(memberId);
62  }
63 
64  /* IDaoEntity */
65 
66  @Override
67  public Object entityId() {
68  return memberId;
69  }
70 
71  @Override
72  public boolean isEmpty() {
73  return memberId == 0;
74  }
75 
76  /* JSONizable */
77 
78  @Override
79  public String toJson() {
80  return toJson(this);
81  }
82 
83  @Override
84  public String toJson(Map<String, Object> properties) {
85  return toJson(this, properties);
86  }
87 
88  public static AxMemberPreferences fromJson(JsonValue value) {
89  return IJSONizable.fromJson(value.toString(), AxMemberPreferences.class);
90  }
91 
92 }
String toJson(Map< String, Object > properties)
static AxMemberPreferences fromJson(JsonValue value)