001/** 002 * 003 * Copyright 2020 Florian Schmaus. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smackx.xdata; 018 019import org.jxmpp.jid.Jid; 020 021public class JidSingleFormField extends SingleValueFormField { 022 023 private final Jid value; 024 025 protected JidSingleFormField(Builder builder) { 026 super(builder); 027 value = builder.value; 028 } 029 030 @Override 031 public Jid getValue() { 032 return value; 033 } 034 035 public Builder asBuilder() { 036 return new Builder(this); 037 } 038 039 public static final class Builder extends FormField.Builder<JidSingleFormField, JidSingleFormField.Builder> { 040 private Jid value; 041 042 private Builder(JidSingleFormField jidSingleFormField) { 043 super(jidSingleFormField); 044 value = jidSingleFormField.getValue(); 045 } 046 047 Builder(String fieldName) { 048 super(fieldName, FormField.Type.jid_single); 049 } 050 051 @Override 052 protected void resetInternal() { 053 value = null; 054 } 055 056 public Builder setValue(Jid value) { 057 this.value = value; 058 return this; 059 } 060 061 @Override 062 public JidSingleFormField build() { 063 return new JidSingleFormField(this); 064 } 065 066 @Override 067 public Builder getThis() { 068 return this; 069 } 070 } 071}