Sometimes people say things that they don't actually mean. Maybe they're angry, upset, depressed, jealous, etc.. You may not ever know the reason they lashed out and said hurtful things to you.
People will hurt you, like it or not, that is a part of the human experience. Sometimes you will get hurt intentionally and sometimes unintentionally. How you respond to that says a lot about your emotional strength and your character. Becoming bitter and generalizing everyone doesn't provide a positive solution or will ever change what happened to you. Building emotional walls, to protect yourself, may make you feel better but it's an illusion.
The emotional walls you hide behind are not protecting you from getting hurt. Those walls have imprisoned you from life and more importantly from moving on with your life. Because at the end of the day, isn't that the most important thing, your life? and how you live it?