001/*
002 * Copyright 2015-2024 the original author or authors
003 *
004 * This software is licensed under the Apache License, Version 2.0,
005 * the GNU Lesser General Public License version 2 or later ("LGPL")
006 * and the WTFPL.
007 * You may choose either license to govern your use of this software only
008 * upon the condition that you accept all of the terms of either
009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
010 */
011package org.minidns.dnslabel;
012
013/**
014 * A DNS label with a leading or trailing hyphen ('-').
015 */
016public final class LeadingOrTrailingHyphenLabel extends NonLdhLabel {
017
018    LeadingOrTrailingHyphenLabel(String label) {
019        super(label);
020    }
021
022    static boolean isLeadingOrTrailingHypenLabelInternal(String label) {
023        if (label.isEmpty()) {
024            return false;
025        }
026
027        if (label.charAt(0) == '-') {
028            return true;
029        }
030
031        if (label.charAt(label.length() - 1) == '-') {
032            return true;
033        }
034
035        return false;
036    }
037}