001package com.streamconverter.path;
002
003/**
004 * 最小限のPath基底クラス
005 *
006 * <p>Don't Ask, Tell原則に従い、matches()メソッドのみを提供する最小実装
007 *
008 * @param <T> コンテキスト型
009 */
010public abstract class AbstractPath<T> implements IPath<T> {
011
012  /**
013   * AbstractPathのコンストラクタ
014   *
015   * @param path パス文字列(構築時に検証される)
016   */
017  protected AbstractPath(String path) {
018    validateAndNormalize(path);
019  }
020
021  /**
022   * パス文字列の検証と正規化
023   *
024   * @param rawPath 生のパス文字列
025   * @throws IllegalArgumentException 不正なパスの場合
026   */
027  protected abstract void validateAndNormalize(String rawPath);
028
029  /**
030   * 文字列がnullまたは空かチェック
031   *
032   * @param str チェック対象文字列
033   * @return nullまたは空の場合true
034   */
035  protected static boolean isNullOrEmpty(String str) {
036    return str == null || str.trim().isEmpty();
037  }
038}