001/**
002 *
003 * Copyright 2019 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.jxmpp.strings.testframework;
018
019public final class ValidJid {
020
021        public final String unnormalizedJid;
022
023        public final String localpart;
024
025        public final String domainpart;
026
027        public final String resourcepart;
028
029        public final String toString;
030
031        // TODO: Add field containing the origin of the JID, i.e. file and row where this jid started.
032        ValidJid(String unnormalizedJid, String localpart, String domainpart, String resourcepart) {
033                this.unnormalizedJid = unnormalizedJid;
034                this.localpart = localpart;
035                this.domainpart = domainpart;
036                this.resourcepart = resourcepart;
037
038                StringBuilder sb = new StringBuilder(
039                                "ValidJid\n" +
040                                "unnormalized: " + unnormalizedJid + '\n'
041                                );
042                if (!localpart.isEmpty()) {
043                        sb.append("localpart   : ").append(localpart).append('\n');
044                }
045                sb.append("domainpart  : ").append(domainpart).append('\n');
046                if (!resourcepart.isEmpty()) {
047                        sb.append("resourcepart: ").append(resourcepart).append('\n');
048                }
049                this.toString = sb.toString();
050        }
051
052        @Override
053        public String toString() {
054                return toString;
055        }
056}